Re: [PATCH v1 1/1] platform/chrome: cros_ec_typec: Put fwnode in error case during ->probe()

From: Prashant Malani
Date: Mon Jun 14 2021 - 17:34:46 EST


Hi Andy,

On Mon, Jun 14, 2021 at 11:33:10PM +0300, Andy Shevchenko wrote:
> device_for_each_child_node() bumps a reference counting of a returned variable.
> We have to balance it whenever we return to the caller.
>
> Fixes: fdc6b21e2444 ("platform/chrome: Add Type C connector class driver")
> Cc: Prashant Malani <pmalani@xxxxxxxxxxxx>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>

Minor nit, but regardless of that:
Reviewed-by: Prashant Malani <pmalani@xxxxxxxxxxxx>

> ---
> drivers/platform/chrome/cros_ec_typec.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 27c068c4c38d..fb03c22fa34d 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -375,6 +375,7 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
> return 0;
>
> unregister_ports:
> + fwnode_handle_put(fwnode);

It reads better to have this at the location where the goto's are called, but
there are several of them. Instead, can you add a 1-line comment explaining that
the reference is left over? It isn't clear even by going a few calls down the
stack of device_for_each_child_node().


Best regards,

-Prashant