[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z0Iw77gpGgIE6fLT@surfacebook.localdomain>
Date: Sat, 23 Nov 2024 21:45:51 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Javier Carrasco <javier.carrasco.cruz@...il.com>
Cc: Pavel Machek <pavel@....cz>, Lee Jones <lee@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
Gene Chen <gene_chen@...htek.com>,
Jacek Anaszewski <jacek.anaszewski@...il.com>,
Bartosz Golaszewski <brgl@...ev.pl>, Chen-Yu Tsai <wens@...e.org>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-sunxi@...ts.linux.dev
Subject: Re: [PATCH 13/18] leds: pca963x: switch to
device_for_each_child_node_scoped()
Fri, Sep 27, 2024 at 01:21:04AM +0200, Javier Carrasco kirjoitti:
> Switch to device_for_each_child_node_scoped() to simplify the code by
> removing the need for calls to fwnode_handle_put() in the error paths.
>
> This also prevents possible memory leaks if new error paths are added
> without the required call to fwnode_handle_put().
>
> After switching to the scoped variant, there is no longer need for a
> jump to 'err', as an immediate return is possible.
...
> if (ret || reg >= chipdef->n_leds) {
> dev_err(dev, "Invalid 'reg' property for node %pfw\n",
> child);
> - ret = -EINVAL;
> - goto err;
> + return -EINVAL;
> }
I'm not sure how interpret this message, but the problem here is the shadowing
of the original error code. Hence I would split this:
if (ret)
return ret; // possibly return dev_err_probe() with another message
if (reg >= chipdef->n_leds)
return dev_err_probe(dev, -EINVAL, "Invalid 'reg' property for node %pfw\n",
child);
...
> if (ret) {
> dev_err(dev, "Failed to register LED for node %pfw\n",
> child);
> - goto err;
> + return ret;
return dev_err_probe(...);
> }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists