From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85BCBC5AC7C for ; Thu, 6 Aug 2026 13:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lWLMNg+LUCwRJZtz2aWErDHgC89WNatFCUB3XLpgYlk=; b=XgHNm0BT7mg081 W4Sa6TnO7tJerVnp/MRow7QQG49EFPMD2znYxeobp4Ge5Gxqutysdwr07auktTn25Pi8yRbJs+nIl ecSZUdVAb9BXXDEzEe5dGbIyYHdyzRIh+vaI/SboClycx6l9xgAn6Af9bsDZaoVmD/cD4tiq7Z7/L PPwvGICumRnFOoiTOfv2HvqZohWQkoSrCpFmCcmhbB1pmtTv1xq1PERDQ/isif5MAG9oVlwxxayID 9hfuCzo++etzQ8phqiqi67FlljSRtOloxkYUxeA2KS4Y6uINEQFVLEC/gKa2j08A3h0Z9NiIeb2fs yIQBCnB+rb20t4GCLHgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wry0E-00000005rxw-0yCM; Thu, 06 Aug 2026 13:19:18 +0000 Received: from mgamail.intel.com ([192.198.163.16]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wry0B-00000005ruv-2Hjk for linux-i3c@lists.infradead.org; Thu, 06 Aug 2026 13:19:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022355; x=1817558355; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m+vaP+hUhXQyQtti8rw2K8d44e4Og780oMqT54taEy0=; b=Y0X6PdP8OcHSGUCaprcplqvihnflNtOq2E30Qtq7FEA1SMv7tyskPtkW r2FXjWJ+kAAiykCYAaCLV5SUmv+mKmLIuUQPJ84qeOQr5PBeNeIO4BXQA 56LnzRC7LFVfv73VQLZQXB2zENzp8+cqd4bdlogkv2mj8TdQQH8mVSUDX ZjONGvX4ZoyyRjATBwn4JgQcunGbTmHxHTYxH03GPe/BheORXCMKJZWju 3PQ1vIhOCSkUWelgQoeuGT60kRjzdM4S5dHGb4KeA3z/s1hApZOjzfw4V 7WEb5+W+YCAj9KXdlWLurMVMkewbtHYz51g6gwfb1I2K/ZZfDxwaboYxY Q==; X-CSE-ConnectionGUID: bDORsR1ZQCKw4dgouLMWkw== X-CSE-MsgGUID: b4AwGzbtRHGgeO+B+YLwQA== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149532" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149532" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2026 06:19:14 -0700 X-CSE-ConnectionGUID: MxIAstuiTqe+XZrgiAh09Q== X-CSE-MsgGUID: EAitVmDZRfeBsJWc2EOqCQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338080" Received: from mkosciow-mobl1.ger.corp.intel.com (HELO ahunter6-desk) ([10.245.244.200]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2026 06:19:11 -0700 From: Adrian Hunter To: alexandre.belloni@bootlin.com Cc: Frank.Li@nxp.com, akhilrajeev@nvidia.com, mukesh.savaliya@oss.qualcomm.com, rafael@kernel.org, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH V4 02/14] i3c: Fix unlocked dereference of dev->desc in i3c_device_get_supported_xfer_mode() Date: Thu, 6 Aug 2026 16:18:45 +0300 Message-ID: <20260806131857.119830-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806131857.119830-1-adrian.hunter@intel.com> References: <20260806131857.119830-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260806_061915_598067_DCF8E5AA X-CRM114-Status: GOOD ( 11.04 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org i3c_device_get_supported_xfer_mode() uses dev->desc to obtain the master controller. However, dev->desc must not be dereferenced unless bus->lock is held, and this function does not take that lock. The function only needs access to the master controller associated with the device's bus. Use dev->bus instead, which is always valid for the lifetime of the device and does not require dereferencing dev->desc. Fixes: 256a21743d91 ("i3c: Add HDR API support") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter --- Changes in V4: None Changes in V3: New patch drivers/i3c/device.c | 2 +- drivers/i3c/internals.h | 5 +++++ drivers/i3c/master.c | 6 ------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index 101eaa77de68..a3778282e84c 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -309,7 +309,7 @@ EXPORT_SYMBOL_GPL(i3c_device_match_id); */ u32 i3c_device_get_supported_xfer_mode(struct i3c_device *dev) { - return i3c_dev_get_master(dev->desc)->this->info.hdr_cap | BIT(I3C_SDR); + return i3c_bus_to_i3c_master(dev->bus)->this->info.hdr_cap | BIT(I3C_SDR); } EXPORT_SYMBOL_GPL(i3c_device_get_supported_xfer_mode); diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h index 0f1f3f766623..86a36b951e0d 100644 --- a/drivers/i3c/internals.h +++ b/drivers/i3c/internals.h @@ -72,4 +72,9 @@ static inline void i3c_readl_fifo(const void __iomem *addr, void *buf, } } +static inline struct i3c_master_controller *i3c_bus_to_i3c_master(struct i3c_bus *i3cbus) +{ + return container_of(i3cbus, struct i3c_master_controller, bus); +} + #endif /* I3C_INTERNAL_H */ diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index d2fb1a110521..c7bb52b71d88 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -102,12 +102,6 @@ void i3c_bus_normaluse_unlock(struct i3c_bus *bus) up_read(&bus->lock); } -static struct i3c_master_controller * -i3c_bus_to_i3c_master(struct i3c_bus *i3cbus) -{ - return container_of(i3cbus, struct i3c_master_controller, bus); -} - static struct i3c_master_controller *dev_to_i3cmaster(struct device *dev) { return container_of(dev, struct i3c_master_controller, dev); -- 2.53.0 -- linux-i3c mailing list linux-i3c@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-i3c