{"id":2857,"url":"https://patchwork.libcamera.org/api/patches/2857/?format=json","web_url":"https://patchwork.libcamera.org/patch/2857/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200218125139.30421-1-kieran.bingham@ideasonboard.com>","date":"2020-02-18T12:51:39","name":"[libcamera-devel] libcamera: media_device: prevent sign extension on casts","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"52caa6cc73a87b7abcf400bc5b5ea9d4d350f693","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2857/mbox/","series":[{"id":686,"url":"https://patchwork.libcamera.org/api/series/686/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=686","date":"2020-02-18T12:51:39","name":"[libcamera-devel] libcamera: media_device: prevent sign extension on casts","version":1,"mbox":"https://patchwork.libcamera.org/series/686/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2857/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2857/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C2F2C60837\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Feb 2020 13:51:44 +0100 (CET)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A6F52F9;\n\tTue, 18 Feb 2020 13:51:44 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1582030304;\n\tbh=NR2letMy/ybK5E9SMk0Y2VtZIBgeBKsSc7HrTjUwX/s=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=qd6wCVc30mR+v6fwGw1EEXUCOU+yn57j4ZerpVvmBAfrkwO8G9lgGin8ddkKavUdl\n\tgjh89fbiDAzcmJ7t12LdpovZ4+Kx//a21XQmNhtSsmS0MSiP8DQzcM45Hg3lOhsmn3\n\tGQIwU40jemIV6KEwV3IW6cBIj+XQIiJ+Hfzwjbck=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Tue, 18 Feb 2020 12:51:39 +0000","Message-Id":"<20200218125139.30421-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: media_device: prevent sign\n\textension on casts","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 18 Feb 2020 12:51:45 -0000"},"content":"Storing the pointer address of the topology structures using a cast to\n__u64 can fail on 32 bit binaries running on a 64 bit kernel due to sign\nextension of the pointer.\n\nConvert the casting to use std::uintptr_t which does not sign-extend the value.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/media_device.cpp | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex e1ae34f88455..2d493e6c895f 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -231,10 +231,10 @@ int MediaDevice::populate()\n \t */\n \twhile (true) {\n \t\ttopology.topology_version = 0;\n-\t\ttopology.ptr_entities = reinterpret_cast<__u64>(ents);\n-\t\ttopology.ptr_interfaces = reinterpret_cast<__u64>(interfaces);\n-\t\ttopology.ptr_links = reinterpret_cast<__u64>(links);\n-\t\ttopology.ptr_pads = reinterpret_cast<__u64>(pads);\n+\t\ttopology.ptr_entities = reinterpret_cast<std::uintptr_t>(ents);\n+\t\ttopology.ptr_interfaces = reinterpret_cast<std::uintptr_t>(interfaces);\n+\t\ttopology.ptr_links = reinterpret_cast<std::uintptr_t>(links);\n+\t\ttopology.ptr_pads = reinterpret_cast<std::uintptr_t>(pads);\n \n \t\tret = ioctl(fd_, MEDIA_IOC_G_TOPOLOGY, &topology);\n \t\tif (ret < 0) {\n","prefixes":["libcamera-devel"]}