From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
To: Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net] igb: Fix potential I2C adapter leak on probe failure
Date: Mon, 16 Nov 2026 22:19:35 +0800 [thread overview]
Message-ID: <20261116-c29ba55625-net-igb@mail.sdu.edu.cn> (raw)
If netdev registration fails after I2C setup, err_register clears the
embedded adapter without unregistering it. I2C clients and the adapter
registration outlive the freed netdev.
Delete the registered adapter instead of clearing its storage.
This issue was found by our static analysis tool under development.
Fixes: 441fc6fdb47a ("igb: Add i2c interface to igb.")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
drivers/net/ethernet/intel/igb/igb_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index d4a897a8c82c..ffb696500d9c 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3657,7 +3657,8 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err_register:
igb_release_hw_control(adapter);
- memset(&adapter->i2c_adap, 0, sizeof(adapter->i2c_adap));
+ if (adapter->i2c_adap.dev.parent)
+ i2c_del_adapter(&adapter->i2c_adap);
err_eeprom:
if (!igb_check_reset_block(hw))
igb_reset_phy(hw);
base-commit: 2e54b3e187300893688c2c7517894f5d96732e05
next reply other threads:[~2026-11-16 14:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 14:19 Guangshuo Li [this message]
2026-11-16 14:22 ` [PATCH net] igb: Fix potential I2C adapter leak on probe failure netdev-bot+sinfo
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=20261116-c29ba55625-net-igb@mail.sdu.edu.cn \
--to=liguangshuo@mail.sdu.edu.cn \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.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