mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Advait Dhamorikar <advaitdhamorikar@gmail.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
	Advait Dhamorikar <advaitdhamorikar@gmail.com>
Subject: [PATCH-next] i3c: master: Fix potentially uninit variable
Date: Tue, 19 Nov 2024 21:09:41 +0530	[thread overview]
Message-ID: <20241119153941.8307-1-advaitdhamorikar@gmail.com> (raw)

devinfo is uninitialized if the condition is not satisfied,
add an else condition to prevent unexpected behaviour.

The variable will contain an arbitrary value left from earlier 
computations in `i3c_device_uevent`.

Signed-off-by: Advait Dhamorikar <advaitdhamorikar@gmail.com>
---
 drivers/i3c/master.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 42310c9a00c2..7594d3793eb0 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -284,6 +284,8 @@ static int i3c_device_uevent(const struct device *dev, struct kobj_uevent_env *e
 
 	if (i3cdev->desc)
 		devinfo = i3cdev->desc->info;
+	else
+		return -ENODEV;
 	manuf = I3C_PID_MANUF_ID(devinfo.pid);
 	part = I3C_PID_PART_ID(devinfo.pid);
 	ext = I3C_PID_EXTRA_INFO(devinfo.pid);
-- 
2.34.1


             reply	other threads:[~2024-11-19 15:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19 15:39 Advait Dhamorikar [this message]
2024-11-26 19:56 ` Advait Dhamorikar
2024-11-26 22:48   ` Alexandre Belloni
2024-11-27 10:14     ` Advait Dhamorikar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241119153941.8307-1-advaitdhamorikar@gmail.com \
    --to=advaitdhamorikar@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-i3c@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®