All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] driver core: return an error when dev_set_name() hasn't happened
@ 2023-08-28 14:58 Andy Shevchenko
  0 siblings, 0 replies; only message in thread
From: Andy Shevchenko @ 2023-08-28 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Saravana Kannan, linux-kernel
  Cc: Rafael J. Wysocki, hdanton, Andy Shevchenko, syzbot+bdfb03b1ec8b342c12cb

The commit d21fdd07cea4 ("driver core: Return proper error code when
dev_set_name() fails") rewrote the logic of handling the dev_set_name()
error codes, but missed the point that initially set error value to
-EINVAL might be rewritten and hence the error path can't be triggered
at some circumstances. To fix this, make sure that error variable is
set to -EINVAL when other conditionals are false.

Reported-by: syzbot+bdfb03b1ec8b342c12cb@syzkaller.appspotmail.com
Fixes: d21fdd07cea4 ("driver core: Return proper error code when dev_set_name() fails")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 0d246c060f86..67ba592afc77 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3538,6 +3538,8 @@ int device_add(struct device *dev)
 	/* subsystems can specify simple device enumeration */
 	else if (dev->bus && dev->bus->dev_name)
 		error = dev_set_name(dev, "%s%u", dev->bus->dev_name, dev->id);
+	else
+		error = -EINVAL;
 	if (error)
 		goto name_error;
 
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-28 14:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 14:58 [PATCH v1 1/1] driver core: return an error when dev_set_name() hasn't happened Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.