mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
HID: wiimote: led_probe with scoped cleanup
Cleanup code in led probe function, using the modern scoped cleanup. This prevents mistakes in future changes to this function. Signed-off-by: Rafael Passos <rafael@rcpassos.me> Reviewed-by: David Rheinsberg <david@readahead.eu> Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
4a487cd0ed
commit
1484db59f5
|
|
@ -339,9 +339,9 @@ static void wiimod_led_set(struct led_classdev *led_dev,
|
|||
static int wiimod_led_probe(const struct wiimod_ops *ops,
|
||||
struct wiimote_data *wdata)
|
||||
{
|
||||
struct led_classdev *led __free(kfree) = NULL;
|
||||
struct device *dev = &wdata->hdev->dev;
|
||||
size_t namesz = strlen(dev_name(dev)) + 9;
|
||||
struct led_classdev *led;
|
||||
char *name;
|
||||
int ret;
|
||||
|
||||
|
|
@ -359,15 +359,14 @@ static int wiimod_led_probe(const struct wiimod_ops *ops,
|
|||
|
||||
wdata->leds[ops->arg] = led;
|
||||
ret = led_classdev_register(dev, led);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
if (ret) {
|
||||
wdata->leds[ops->arg] = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
retain_and_null_ptr(led);
|
||||
|
||||
return 0;
|
||||
|
||||
err_free:
|
||||
wdata->leds[ops->arg] = NULL;
|
||||
kfree(led);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void wiimod_led_remove(const struct wiimod_ops *ops,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user