Commit 0d2a776e authored by Florinel Iordache's avatar Florinel Iordache Committed by Greg Kroah-Hartman

fsl/fman: fix dereference null return value

[ Upstream commit 05720546 ]

Check before using returned value to avoid dereferencing null pointer.

Fixes: 18a6c85f ("fsl/fman: Add FMan Port Support")
Signed-off-by: default avatarFlorinel Iordache <florinel.iordache@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent eb8119b9
......@@ -1623,6 +1623,7 @@ static int fman_port_probe(struct platform_device *of_dev)
struct fman_port *port;
struct fman *fman;
struct device_node *fm_node, *port_node;
struct platform_device *fm_pdev;
struct resource res;
struct resource *dev_res;
u32 val;
......@@ -1647,8 +1648,14 @@ static int fman_port_probe(struct platform_device *of_dev)
goto return_err;
}
fman = dev_get_drvdata(&of_find_device_by_node(fm_node)->dev);
fm_pdev = of_find_device_by_node(fm_node);
of_node_put(fm_node);
if (!fm_pdev) {
err = -EINVAL;
goto return_err;
}
fman = dev_get_drvdata(&fm_pdev->dev);
if (!fman) {
err = -EINVAL;
goto return_err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment