[libcamera-devel] [PATCH] libcamera: media_device: prevent sign extension on casts
Kieran Bingham
kieran.bingham at ideasonboard.com
Tue Feb 18 13:51:39 CET 2020
Storing the pointer address of the topology structures using a cast to
__u64 can fail on 32 bit binaries running on a 64 bit kernel due to sign
extension of the pointer.
Convert the casting to use std::uintptr_t which does not sign-extend the value.
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
src/libcamera/media_device.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index e1ae34f88455..2d493e6c895f 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -231,10 +231,10 @@ int MediaDevice::populate()
*/
while (true) {
topology.topology_version = 0;
- topology.ptr_entities = reinterpret_cast<__u64>(ents);
- topology.ptr_interfaces = reinterpret_cast<__u64>(interfaces);
- topology.ptr_links = reinterpret_cast<__u64>(links);
- topology.ptr_pads = reinterpret_cast<__u64>(pads);
+ topology.ptr_entities = reinterpret_cast<std::uintptr_t>(ents);
+ topology.ptr_interfaces = reinterpret_cast<std::uintptr_t>(interfaces);
+ topology.ptr_links = reinterpret_cast<std::uintptr_t>(links);
+ topology.ptr_pads = reinterpret_cast<std::uintptr_t>(pads);
ret = ioctl(fd_, MEDIA_IOC_G_TOPOLOGY, &topology);
if (ret < 0) {
--
2.20.1
More information about the libcamera-devel
mailing list