Re: [PATCH 2/4] pwm: omap-dmtimer: simplify error handling

From: Markus Elfring
Date: Mon Nov 11 2019 - 08:32:38 EST


> Implementation note: The put: label was never reached without a goto and
> ret being unequal to 0, so the removed return statement is fine.

This can look fine (in principle) because the label was repositioned here.
Do you really want to call the function âof_node_putâ at two places now?


> +++ b/drivers/pwm/pwm-omap-dmtimer.c
â
> omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
> if (!omap) {
> - pdata->free(dm_timer);
> - return -ENOMEM;
> + ret = -ENOMEM;
> + goto err_alloc_omap;
> }
â

I suggest to reconsider your label name selection according to
the Linux coding style.


> @@ -339,13 +334,28 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
â
> +err_pwmchip_add:
> +
> + /*
> + * *omap is allocated using devm_kzalloc,
> + * so no free necessary here
> + */
> +err_alloc_omap:
> +
> + pdata->free(dm_timer);

Would the use of the label âfree_dm_timerâ be more appropriate?


> +put:
> + of_node_put(timer);
â

Can the label âput_nodeâ be nicer?

Regards,
Markus