Skip to content

Commit 1687f01

Browse files
YuKuai-huaweigregkh
authored andcommitted
leds: netxbig: add missing put_device() call in netxbig_leds_get_of_pdata()
[ Upstream commit 311066a ] if of_find_device_by_node() succeed, netxbig_leds_get_of_pdata() doesn't have a corresponding put_device(). Thus add jump target to fix the exception handling for this function implementation. Fixes: 2976b17 ("leds: netxbig: add device tree binding") Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4827f0c commit 1687f01

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

‎drivers/leds/leds-netxbig.c‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,31 +448,39 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
448448
gpio_ext = devm_kzalloc(dev, sizeof(*gpio_ext), GFP_KERNEL);
449449
if (!gpio_ext) {
450450
of_node_put(gpio_ext_np);
451-
return -ENOMEM;
451+
ret = -ENOMEM;
452+
goto put_device;
452453
}
453454
ret = netxbig_gpio_ext_get(dev, gpio_ext_dev, gpio_ext);
454455
of_node_put(gpio_ext_np);
455456
if (ret)
456-
return ret;
457+
goto put_device;
457458
pdata->gpio_ext = gpio_ext;
458459

459460
/* Timers (optional) */
460461
ret = of_property_count_u32_elems(np, "timers");
461462
if (ret > 0) {
462-
if (ret % 3)
463-
return -EINVAL;
463+
if (ret % 3) {
464+
ret = -EINVAL;
465+
goto put_device;
466+
}
467+
464468
num_timers = ret / 3;
465469
timers = devm_kcalloc(dev, num_timers, sizeof(*timers),
466470
GFP_KERNEL);
467-
if (!timers)
468-
return -ENOMEM;
471+
if (!timers) {
472+
ret = -ENOMEM;
473+
goto put_device;
474+
}
469475
for (i = 0; i < num_timers; i++) {
470476
u32 tmp;
471477

472478
of_property_read_u32_index(np, "timers", 3 * i,
473479
&timers[i].mode);
474-
if (timers[i].mode >= NETXBIG_LED_MODE_NUM)
475-
return -EINVAL;
480+
if (timers[i].mode >= NETXBIG_LED_MODE_NUM) {
481+
ret = -EINVAL;
482+
goto put_device;
483+
}
476484
of_property_read_u32_index(np, "timers",
477485
3 * i + 1, &tmp);
478486
timers[i].delay_on = tmp;
@@ -488,12 +496,15 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
488496
num_leds = of_get_available_child_count(np);
489497
if (!num_leds) {
490498
dev_err(dev, "No LED subnodes found in DT\n");
491-
return -ENODEV;
499+
ret = -ENODEV;
500+
goto put_device;
492501
}
493502

494503
leds = devm_kcalloc(dev, num_leds, sizeof(*leds), GFP_KERNEL);
495-
if (!leds)
496-
return -ENOMEM;
504+
if (!leds) {
505+
ret = -ENOMEM;
506+
goto put_device;
507+
}
497508

498509
led = leds;
499510
for_each_available_child_of_node(np, child) {
@@ -574,6 +585,8 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
574585

575586
err_node_put:
576587
of_node_put(child);
588+
put_device:
589+
put_device(gpio_ext_dev);
577590
return ret;
578591
}
579592

0 commit comments

Comments
 (0)