Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: spi-byte: Call of_node_put() on error path

Add a missing call to of_node_put(np) on error.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240606173037.3091598-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Andy Shevchenko and committed by
Lee Jones
7f9ab862 e1524a62

+5 -1
+5 -1
drivers/leds/leds-spi-byte.c
··· 91 91 dev_err(dev, "Device must have exactly one LED sub-node."); 92 92 return -EINVAL; 93 93 } 94 - child = of_get_next_available_child(dev_of_node(dev), NULL); 95 94 96 95 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); 97 96 if (!led) ··· 103 104 led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value; 104 105 led->ldev.brightness_set_blocking = spi_byte_brightness_set_blocking; 105 106 107 + child = of_get_next_available_child(dev_of_node(dev), NULL); 106 108 state = of_get_property(child, "default-state", NULL); 107 109 if (state) { 108 110 if (!strcmp(state, "on")) { 109 111 led->ldev.brightness = led->ldev.max_brightness; 110 112 } else if (strcmp(state, "off")) { 113 + of_node_put(child); 111 114 /* all other cases except "off" */ 112 115 dev_err(dev, "default-state can only be 'on' or 'off'"); 113 116 return -EINVAL; ··· 124 123 125 124 ret = devm_led_classdev_register_ext(&spi->dev, &led->ldev, &init_data); 126 125 if (ret) { 126 + of_node_put(child); 127 127 mutex_destroy(&led->mutex); 128 128 return ret; 129 129 } 130 + 131 + of_node_put(child); 130 132 spi_set_drvdata(spi, led); 131 133 132 134 return 0;