* [PATCH] usb: typec: retimer: Check dev_set_name() return value
@ 2023-10-14 9:24 Zhang Shurong
2023-10-14 14:39 ` Alan Stern
2023-10-16 17:47 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Zhang Shurong @ 2023-10-14 9:24 UTC (permalink / raw)
To: heikki.krogerus; +Cc: gregkh, linux-usb, linux-kernel, Zhang Shurong
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@foxmail.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: typec: retimer: Check dev_set_name() return value
2023-10-14 9:24 [PATCH] usb: typec: retimer: Check dev_set_name() return value Zhang Shurong
@ 2023-10-14 14:39 ` Alan Stern
2023-10-16 17:47 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Alan Stern @ 2023-10-14 14:39 UTC (permalink / raw)
To: Zhang Shurong; +Cc: heikki.krogerus, gregkh, linux-usb, linux-kernel
On Sat, Oct 14, 2023 at 05:24:53PM +0800, Zhang Shurong wrote:
> 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@foxmail.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) {
It should not be necessary to do this. If dev_set_name() fails then
device_add() will also fail.
Alan Stern
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: typec: retimer: Check dev_set_name() return value
2023-10-14 9:24 [PATCH] usb: typec: retimer: Check dev_set_name() return value Zhang Shurong
2023-10-14 14:39 ` Alan Stern
@ 2023-10-16 17:47 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2023-10-16 17:47 UTC (permalink / raw)
To: Zhang Shurong; +Cc: heikki.krogerus, linux-usb, linux-kernel
On Sat, Oct 14, 2023 at 05:24:53PM +0800, Zhang Shurong wrote:
> 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@foxmail.com>
> ---
> drivers/usb/typec/retimer.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
How was this found?
How was this tested?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-16 17:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-14 9:24 [PATCH] usb: typec: retimer: Check dev_set_name() return value Zhang Shurong
2023-10-14 14:39 ` Alan Stern
2023-10-16 17:47 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox