[PATCH] net: ethernet: mtk_wed: Fix missing of_node_put() in mtk_wed_wo_hardware_init()

Leon Romanovsky leon at kernel.org
Sun Dec 4 04:32:44 PST 2022


On Fri, Dec 02, 2022 at 08:30:29AM +0000, Yuan Can wrote:
> The np needs to be released through of_node_put() in the error handling
> path of mtk_wed_wo_hardware_init().
> 
> Fixes: 799684448e3e ("net: ethernet: mtk_wed: introduce wed wo support")
> Signed-off-by: Yuan Can <yuancan at huawei.com>
> ---
>  drivers/net/ethernet/mediatek/mtk_wed_wo.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Please use [PATCH net-next] ... format in title.

> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_wed_wo.c b/drivers/net/ethernet/mediatek/mtk_wed_wo.c
> index 4754b6db009e..d61bd0b11331 100644
> --- a/drivers/net/ethernet/mediatek/mtk_wed_wo.c
> +++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.c
> @@ -407,8 +407,10 @@ mtk_wed_wo_hardware_init(struct mtk_wed_wo *wo)
>  		return -ENODEV;
>  
>  	wo->mmio.regs = syscon_regmap_lookup_by_phandle(np, NULL);
> -	if (IS_ERR_OR_NULL(wo->mmio.regs))

syscon_regmap_lookup_by_phandle() returns or error or valid pointer.
The right check needs to be IS_ERR(wo->mmio.regs)

Thanks

> -		return PTR_ERR(wo->mmio.regs);
> +	if (IS_ERR_OR_NULL(wo->mmio.regs)) {
> +		ret = PTR_ERR(wo->mmio.regs);
> +		goto error_put;
> +	}
>  
>  	wo->mmio.irq = irq_of_parse_and_map(np, 0);
>  	wo->mmio.irq_mask = MTK_WED_WO_ALL_INT_MASK;
> @@ -456,7 +458,8 @@ mtk_wed_wo_hardware_init(struct mtk_wed_wo *wo)
>  
>  error:
>  	devm_free_irq(wo->hw->dev, wo->mmio.irq, wo);
> -
> +error_put:
> +	of_node_put(np);
>  	return ret;
>  }
>  
> -- 
> 2.17.1
> 



More information about the Linux-mediatek mailing list