From patchwork Tue Feb 18 12:51:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2857 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C2F2C60837 for ; Tue, 18 Feb 2020 13:51:44 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A6F52F9; Tue, 18 Feb 2020 13:51:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582030304; bh=NR2letMy/ybK5E9SMk0Y2VtZIBgeBKsSc7HrTjUwX/s=; h=From:To:Cc:Subject:Date:From; b=qd6wCVc30mR+v6fwGw1EEXUCOU+yn57j4ZerpVvmBAfrkwO8G9lgGin8ddkKavUdl gjh89fbiDAzcmJ7t12LdpovZ4+Kx//a21XQmNhtSsmS0MSiP8DQzcM45Hg3lOhsmn3 GQIwU40jemIV6KEwV3IW6cBIj+XQIiJ+Hfzwjbck= From: Kieran Bingham To: libcamera devel 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 Subject: [libcamera-devel] [PATCH] libcamera: media_device: prevent sign extension on casts X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Feb 2020 12:51:45 -0000 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 Reviewed-by: Laurent Pinchart --- 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(ents); + topology.ptr_interfaces = reinterpret_cast(interfaces); + topology.ptr_links = reinterpret_cast(links); + topology.ptr_pads = reinterpret_cast(pads); ret = ioctl(fd_, MEDIA_IOC_G_TOPOLOGY, &topology); if (ret < 0) {