[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_A06A37B6A0C0643DEC1524501525866FAC09@qq.com>
Date: Sat, 14 Oct 2023 17:24:53 +0800
From: Zhang Shurong <zhang_shurong@...mail.com>
To: heikki.krogerus@...ux.intel.com
Cc: gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
Zhang Shurong <zhang_shurong@...mail.com>
Subject: [PATCH] usb: typec: retimer: Check dev_set_name() return value
It's possible that dev_set_name() returns -ENOMEM.
We fix this by catching the error and handling it.
Fixes: ddaf8d96f93b ("usb: typec: Add support for retimers")
Signed-off-by: Zhang Shurong <zhang_shurong@...mail.com>
---
drivers/usb/typec/retimer.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/typec/retimer.c b/drivers/usb/typec/retimer.c
index 4a7d1b5c4d86..f163856a78cd 100644
--- a/drivers/usb/typec/retimer.c
+++ b/drivers/usb/typec/retimer.c
@@ -122,8 +122,13 @@ typec_retimer_register(struct device *parent, const struct typec_retimer_desc *d
retimer->dev.class = &retimer_class;
retimer->dev.type = &typec_retimer_dev_type;
retimer->dev.driver_data = desc->drvdata;
- dev_set_name(&retimer->dev, "%s-retimer",
+ ret = dev_set_name(&retimer->dev, "%s-retimer",
desc->name ? desc->name : dev_name(parent));
+ if (ret) {
+ dev_err(parent, "failed to register retimer (%d)\n", ret);
+ put_device(&retimer->dev);
+ return ERR_PTR(ret);
+ }
ret = device_add(&retimer->dev);
if (ret) {
--
2.30.2
Powered by blists - more mailing lists