From: Yu Kuai <yukuai3@huawei.com>
To: <madalin.bucur@nxp.com>, <davem@davemloft.net>, <kuba@kernel.org>,
<florinel.iordache@nxp.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<yukuai3@huawei.com>, <yi.zhang@huawei.com>
Subject: [PATCH V2] fsl/fman: add missing put_devcie() call in fman_port_probe()
Date: Tue, 3 Nov 2020 19:23:23 +0800 [thread overview]
Message-ID: <20201103112323.1077040-1-yukuai3@huawei.com> (raw)
In-Reply-To: <20201031105418.2304011-1-yukuai3@huawei.com>
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@huawei.com>
---
.../net/ethernet/freescale/fman/fman_port.c | 23 +++++++++----------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
index d9baac0dbc7d..4ae5d844d1f5 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.c
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -1792,20 +1792,21 @@ 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;
}
+ of_node_put(port_node);
fm_pdev = of_find_device_by_node(fm_node);
of_node_put(fm_node);
if (!fm_pdev) {
err = -EINVAL;
- goto return_err;
+ goto free_port;
}
fman = dev_get_drvdata(&fm_pdev->dev);
if (!fman) {
err = -EINVAL;
- goto return_err;
+ goto put_device;
}
err = of_property_read_u32(port_node, "cell-index", &val);
@@ -1813,7 +1814,7 @@ static int fman_port_probe(struct platform_device *of_dev)
dev_err(port->dev, "%s: reading cell-index for %pOF failed\n",
__func__, port_node);
err = -EINVAL;
- goto return_err;
+ goto put_device;
}
port_id = (u8)val;
port->dts_params.id = port_id;
@@ -1847,7 +1848,7 @@ static int fman_port_probe(struct platform_device *of_dev)
} else {
dev_err(port->dev, "%s: Illegal port type\n", __func__);
err = -EINVAL;
- goto return_err;
+ goto put_device;
}
port->dts_params.type = port_type;
@@ -1861,7 +1862,7 @@ static int fman_port_probe(struct platform_device *of_dev)
dev_err(port->dev, "%s: incorrect qman-channel-id\n",
__func__);
err = -EINVAL;
- goto return_err;
+ goto put_device;
}
port->dts_params.qman_channel_id = qman_channel_id;
}
@@ -1871,20 +1872,18 @@ static int fman_port_probe(struct platform_device *of_dev)
dev_err(port->dev, "%s: of_address_to_resource() failed\n",
__func__);
err = -ENOMEM;
- goto return_err;
+ goto put_device;
}
port->dts_params.fman = fman;
- of_node_put(port_node);
-
dev_res = __devm_request_region(port->dev, &res, res.start,
resource_size(&res), "fman-port");
if (!dev_res) {
dev_err(port->dev, "%s: __devm_request_region() failed\n",
__func__);
err = -EINVAL;
- goto free_port;
+ goto put_device;
}
port->dts_params.base_addr = devm_ioremap(port->dev, res.start,
@@ -1896,8 +1895,8 @@ static int fman_port_probe(struct platform_device *of_dev)
return 0;
-return_err:
- of_node_put(port_node);
+put_device:
+ put_device(&fm_pdev->dev);
free_port:
kfree(port);
return err;
--
2.25.4
next prev parent reply other threads:[~2020-11-03 11:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-31 10:54 [PATCH] fsl/fman: add missing put_devcie() call in fman_port_probe() Yu Kuai
2020-11-03 1:30 ` Jakub Kicinski
2020-11-03 11:09 ` yukuai (C)
2020-11-03 11:23 ` Yu Kuai [this message]
2020-11-05 1:31 ` [PATCH V2] " Jakub Kicinski
2020-11-06 21:59 ` Madalin Bucur (OSS)
2020-11-07 9:09 ` [PATCH V3] " Yu Kuai
2020-11-07 22:09 ` Jakub Kicinski
2020-11-09 13:11 ` yukuai (C)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201103112323.1077040-1-yukuai3@huawei.com \
--to=yukuai3@huawei.com \
--cc=davem@davemloft.net \
--cc=florinel.iordache@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).