From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2FA019F416 for ; Wed, 14 May 2025 09:32:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747215123; cv=none; b=MIXhulQzT/D52xpJXkWjrBnVaHcKGr98/pxYyWukuce6WcTIDhWmKCi8X1mDwJtOz3wnivU2ud/opitj3kWBfIU3/4QgHYL+mvTDuHhFdqEAb8of9HWrr2R0bt/IZJyG+jkrPxnF4Ghq6B5oi9/eZAfnPKOeoLXHeOJj1mX/2A0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747215123; c=relaxed/simple; bh=DKJPQc2UnDSjTx7nZLHqJP7cJoeJGHqZa8YDeDrbSlY=; h=Mime-Version:Content-Type:Date:Message-Id:To:From:Subject:Cc: References:In-Reply-To; b=Z+A+U0I05fA1ncT+SxHigLb5sWy5If3z6Gg0ETw6mFXJOZO46r9tF8fwGJZTBOaCbuBYSYfpG1I8Oug4U28c3DEnrvUZb9lSs5ay/jcSaeW19DA8cEMihG31NNLbFnb/o/OrAJ/MKHvS3i8qUgh5ydV4wJXJhq7BZQBVN8aZ894= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=JK1vTSb7; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="JK1vTSb7" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8B35043AD3; Wed, 14 May 2025 09:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1747215119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dfv45bnichpjCAGq207bFcZlXwMMK/d535qeWmESpzY=; b=JK1vTSb76jiCXGtp9jYMuHjcCO1yDmVHmnQ5TSFIkWkhTBGTUIzhZxb3d1FITdkaFV5bPX 5bFjWFpVpWu/PHCApYZ5jXDqP60eDUXjIBeLnpt1IJa6gmtIRUaOvk+fMv0QYoHVjgVxHl 8VLOqKSIYHf2GaV2ahgX6ugssAM8UuFejKQdrYhNRQiQvkUi0a0jnll3x9Y42EVzT9VUt0 VbHmkZkwW/Uzdvjx5EePlz5wquWTDY0L1AT6yM0G7w/bE13tYOoi+gIE9TyXMJVUemypy1 0LyT+4f4JaGQRskZYQbBA35TZ88s0sF3BxwIKBtyuaOnwfNMWJMb/X/KQul16g== Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 14 May 2025 11:31:57 +0200 Message-Id: To: "Linus Walleij" , "Yuanjun Gong" From: =?utf-8?q?Th=C3=A9o_Lebrun?= Subject: Re: [PATCH 1/1] drivers/i2c: fix a potential null pointer dereference Cc: "Andi Shyti" , X-Mailer: aerc 0.20.1-0-g2ecb8770224a References: <20250513123754.3041911-1-ruc_gongyuanjun@163.com> In-Reply-To: X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeftdeiieefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpegggfgtfffkvffhufevofhfjgesthhqredtredtjeenucfhrhhomhepvfhhrohoucfnvggsrhhunhcuoehthhgvohdrlhgvsghruhhnsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpeeutdeugfdtffefhfefleeiiefgleefueeltefgjedtueejjedvhfeugfeikeekveenucffohhmrghinhepsghoohhtlhhinhdrtghomhenucfkphepudejiedrudeiuddrvdefvddruddvleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedujeeirdduiedurddvfedvrdduvdelpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehthhgvohdrlhgvsghruhhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeegpdhrtghpthhtoheplhhinhhushdrfigrlhhlvghijheslhhinhgrrhhordhorhhgpdhrtghpthhtoheprhhutggpghhonhhghihurghnjhhunhesudeifedrtghomhdprhgtphhtthhopegrnhguihdrshhhhihtiheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqihdvtgesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: theo.lebrun@bootlin.com Hello Linus, Yuanjun, On Wed May 14, 2025 at 12:10 AM CEST, Linus Walleij wrote: > On Tue, May 13, 2025 at 2:38=E2=80=AFPM Yuanjun Gong wrote: > >> Add check to *priv to make sure the input *dev is not NULL, >> and to avoid a potential null pointer dereference. >> >> Signed-off-by: Yuanjun Gong > > Why is this a problem? Reading nmk_i2c_probe(): > > priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > if (!priv) > return -ENOMEM; > > OK so priv is not NULL. > > amba_set_drvdata(adev, priv); > > It is unconditionally assigned to the AMBA device. > > Surely runtime resume isn't called before probe() has commenced > successfully? > > I don't understand when this condition can occur. > > Also including Theo on this, he is the major industrial user of this driv= er now. Thanks for the Cc; I agree with your reading of the code and don't see the issue. Thanks, -- Th=C3=A9o Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com