Re: [PATCH V3] fsl/fman: add missing put_devcie() call in fman_port_probe()

From: yukuai (C)
Date: Mon Nov 09 2020 - 08:11:37 EST


在 2020/11/08 6:09, Jakub Kicinski 写道:
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...

Sincerely apologize for that stupid mistake...


Also does the reference to put_device() not have to be released when
this function succeeds?


I'm not sure about that, since fman_port_driver doesn't define other
interface, maybe it reasonable to release it here.

}

@@ -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);

.