Re: [PATCH V3] fsl/fman: add missing put_devcie() call in fman_port_probe()
From: Jakub Kicinski
Date: Sat Nov 07 2020 - 17:09:56 EST
On Sat, 7 Nov 2020 17:09:25 +0800 Yu Kuai wrote:
> if of_find_device_by_node() succeed, fman_port_probe() doesn't have a
> corresponding put_device(). Thus add jump target to fix the exception
> handling for this function implementation.
>
> Fixes: 0572054617f3 ("fsl/fman: fix dereference null return value")
> Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
> @@ -1792,20 +1792,20 @@ static int fman_port_probe(struct platform_device *of_dev)
> if (!fm_node) {
> dev_err(port->dev, "%s: of_get_parent() failed\n", __func__);
> err = -ENODEV;
> - goto return_err;
> + goto free_port;
And now you no longer put port_node if jumping from here...
Also does the reference to put_device() not have to be released when
this function succeeds?
> }
> @@ -1896,7 +1895,9 @@ static int fman_port_probe(struct platform_device *of_dev)
>
> return 0;
>
> -return_err:
> +put_device:
> + put_device(&fm_pdev->dev);
> +put_node:
> of_node_put(port_node);
> free_port:
> kfree(port);