public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drivers/i2c: fix a potential null pointer dereference
@ 2025-05-13 12:37 Yuanjun Gong
  2025-05-13 22:10 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Yuanjun Gong @ 2025-05-13 12:37 UTC (permalink / raw)
  To: Linus Walleij, Andi Shyti, linux-i2c; +Cc: Yuanjun Gong

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 <ruc_gongyuanjun@163.com>
---
 drivers/i2c/busses/i2c-nomadik.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index d2877e4cc28d..ebc600f3a7c8 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -968,6 +968,9 @@ static int nmk_i2c_runtime_resume(struct device *dev)
 	struct nmk_i2c_dev *priv = amba_get_drvdata(adev);
 	int ret;
 
+	if (!priv)
+		return -EINVAL;
+
 	ret = clk_prepare_enable(priv->clk);
 	if (ret) {
 		dev_err(dev, "can't prepare_enable clock\n");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-14 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13 12:37 [PATCH 1/1] drivers/i2c: fix a potential null pointer dereference Yuanjun Gong
2025-05-13 22:10 ` Linus Walleij
2025-05-14  9:31   ` Théo Lebrun
2025-05-14 15:05     ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox