Skip to content

Commit

Permalink
BACKPORT: usb: typec: mux: Check dev_set_name() return value
Browse files Browse the repository at this point in the history
It's possible that dev_set_name() returns -ENOMEM, catch and handle this.

Bug: 254441685
Fixes: 3370db35193b ("usb: typec: Registering real device entries for the muxes")
Reported-by: Andy Shevchenko <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Acked-by: Heikki Krogerus <[email protected]>
Signed-off-by: Bjorn Andersson <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit b9fa0292490db39d6542f514117333d366ec0011)
[Lee: dev_set_name() line was a little different - trivial fix-up]
Signed-off-by: Lee Jones <[email protected]>
Change-Id: I3bfcc613b7f6b08d01f1aab9dce71a05abe25bf6
  • Loading branch information
andersson authored and LucasBlackLu committed Jan 31, 2024
1 parent 388566b commit d90c8e5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/usb/typec/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ typec_switch_register(struct device *parent,
sw->dev.class = &typec_mux_class;
sw->dev.type = &typec_switch_dev_type;
sw->dev.driver_data = desc->drvdata;
dev_set_name(&sw->dev, "%s-switch", dev_name(parent));
ret = dev_set_name(&sw->dev, "%s-switch", dev_name(parent));
if (ret) {
put_device(&sw->dev);
return ERR_PTR(ret);
}

ret = device_add(&sw->dev);
if (ret) {
Expand Down Expand Up @@ -327,7 +331,11 @@ typec_mux_register(struct device *parent, const struct typec_mux_desc *desc)
mux->dev.class = &typec_mux_class;
mux->dev.type = &typec_mux_dev_type;
mux->dev.driver_data = desc->drvdata;
dev_set_name(&mux->dev, "%s-mux", dev_name(parent));
ret = dev_set_name(&mux->dev, "%s-mux", dev_name(parent));
if (ret) {
put_device(&mux->dev);
return ERR_PTR(ret);
}

ret = device_add(&mux->dev);
if (ret) {
Expand Down

0 comments on commit d90c8e5

Please sign in to comment.