From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Aleksandr Mishin <amishin@t-argos.ru>,
Paolo Abeni <pabeni@redhat.com>, Sasha Levin <sashal@kernel.org>,
madalin.bucur@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
linux@armlinux.org.uk, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 6.6 09/15] fsl/fman: Save device references taken in mac_probe()
Date: Mon, 28 Oct 2024 06:52:05 -0400 [thread overview]
Message-ID: <20241028105218.3559888-9-sashal@kernel.org> (raw)
In-Reply-To: <20241028105218.3559888-1-sashal@kernel.org>
From: Aleksandr Mishin <amishin@t-argos.ru>
[ Upstream commit efeddd552ec6767e4c8884caa516ac80b65f8823 ]
In mac_probe() there are calls to of_find_device_by_node() which takes
references to of_dev->dev. These references are not saved and not released
later on error path in mac_probe() and in mac_remove().
Add new fields into mac_device structure to save references taken for
future use in mac_probe() and mac_remove().
This is a preparation for further reference leaks fix.
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/freescale/fman/mac.c | 6 ++++--
drivers/net/ethernet/freescale/fman/mac.h | 6 +++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 9767586b4eb32..9b863db0bf087 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -197,6 +197,7 @@ static int mac_probe(struct platform_device *_of_dev)
err = -EINVAL;
goto _return_of_node_put;
}
+ mac_dev->fman_dev = &of_dev->dev;
/* Get the FMan cell-index */
err = of_property_read_u32(dev_node, "cell-index", &val);
@@ -208,7 +209,7 @@ static int mac_probe(struct platform_device *_of_dev)
/* cell-index 0 => FMan id 1 */
fman_id = (u8)(val + 1);
- priv->fman = fman_bind(&of_dev->dev);
+ priv->fman = fman_bind(mac_dev->fman_dev);
if (!priv->fman) {
dev_err(dev, "fman_bind(%pOF) failed\n", dev_node);
err = -ENODEV;
@@ -284,8 +285,9 @@ static int mac_probe(struct platform_device *_of_dev)
err = -EINVAL;
goto _return_of_node_put;
}
+ mac_dev->fman_port_devs[i] = &of_dev->dev;
- mac_dev->port[i] = fman_port_bind(&of_dev->dev);
+ mac_dev->port[i] = fman_port_bind(mac_dev->fman_port_devs[i]);
if (!mac_dev->port[i]) {
dev_err(dev, "dev_get_drvdata(%pOF) failed\n",
dev_node);
diff --git a/drivers/net/ethernet/freescale/fman/mac.h b/drivers/net/ethernet/freescale/fman/mac.h
index fe747915cc737..8b5b43d50f8ef 100644
--- a/drivers/net/ethernet/freescale/fman/mac.h
+++ b/drivers/net/ethernet/freescale/fman/mac.h
@@ -19,12 +19,13 @@
struct fman_mac;
struct mac_priv_s;
+#define PORT_NUM 2
struct mac_device {
void __iomem *vaddr;
struct device *dev;
struct resource *res;
u8 addr[ETH_ALEN];
- struct fman_port *port[2];
+ struct fman_port *port[PORT_NUM];
struct phylink *phylink;
struct phylink_config phylink_config;
phy_interface_t phy_if;
@@ -52,6 +53,9 @@ struct mac_device {
struct fman_mac *fman_mac;
struct mac_priv_s *priv;
+
+ struct device *fman_dev;
+ struct device *fman_port_devs[PORT_NUM];
};
static inline struct mac_device
--
2.43.0
next prev parent reply other threads:[~2024-10-28 10:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 10:51 [PATCH AUTOSEL 6.6 01/15] xfrm: extract dst lookup parameters into a struct Sasha Levin
2024-10-28 10:51 ` [PATCH AUTOSEL 6.6 02/15] ASoC: amd: yc: Add quirk for ASUS Vivobook S15 M3502RA Sasha Levin
2024-10-28 10:51 ` [PATCH AUTOSEL 6.6 03/15] ASoC: fsl_esai: change dev_warn to dev_dbg in irq handler Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 04/15] ASoC: amd: yc: Fix non-functional mic on ASUS E1404FA Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 05/15] fs: Fix uninitialized value issue in from_kuid and from_kgid Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 06/15] HID: multitouch: Add quirk for Logitech Bolt receiver w/ Casa touchpad Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 07/15] HID: lenovo: Add support for Thinkpad X1 Tablet Gen 3 keyboard Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 08/15] RISCV: KVM: use raw_spinlock for critical section in imsic Sasha Levin
2024-10-28 10:52 ` Sasha Levin [this message]
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 10/15] ASoC: rt722-sdca: increase clk_stop_timeout to fix clock stop issue Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 11/15] LoongArch: Use "Exception return address" to comment ERA Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 12/15] platform/x86: dell-wmi: Ignore suspend notifications Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 13/15] ASoC: fsl_micfil: Add sample rate constraint Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 14/15] net: usb: qmi_wwan: add Fibocom FG132 0x0112 composition Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.6 15/15] bpf: Check validity of link->type in bpf_link_show_fdinfo() Sasha Levin
2024-11-24 17:28 ` [PATCH AUTOSEL 6.6 01/15] xfrm: extract dst lookup parameters into a struct Pavel Machek
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=20241028105218.3559888-9-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=amishin@t-argos.ru \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®