[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <000000000000c3ec270621f6773f@google.com>
Date: Thu, 12 Sep 2024 18:51:55 -0700
From: syzbot <syzbot+e9ed4e4368d450c8f9db@...kaller.appspotmail.com>
To: linux-kernel@...r.kernel.org
Subject: Re: [syzbot] Re: [syzbot] [net?] WARNING: refcount bug in ethnl_phy_done
For archival purposes, forwarding an incoming command email to
linux-kernel@...r.kernel.org.
***
Subject: Re: [syzbot] [net?] WARNING: refcount bug in ethnl_phy_done
Author: lizhi.xu@...driver.com
Distinguish whether dev is initialized by phy start or phy doit
#syz test
diff --git a/net/ethtool/phy.c b/net/ethtool/phy.c
index 4ef7c6e32d10..fe11de6bddab 100644
--- a/net/ethtool/phy.c
+++ b/net/ethtool/phy.c
@@ -13,6 +13,7 @@
struct phy_req_info {
struct ethnl_req_info base;
struct phy_device_node *pdn;
+ u8 dev_start_doit;
};
#define PHY_REQINFO(__req_base) \
@@ -157,6 +158,9 @@ int ethnl_phy_doit(struct sk_buff *skb, struct genl_info *info)
if (ret < 0)
return ret;
+ if (req_info.base.dev && !req_info.dev_start_doit)
+ req_info.dev_start_doit = 2;
+
rtnl_lock();
ret = ethnl_phy_parse_request(&req_info.base, tb, info->extack);
@@ -223,10 +227,14 @@ int ethnl_phy_start(struct netlink_callback *cb)
false);
ctx->ifindex = 0;
ctx->phy_index = 0;
+ ctx->phy_req_info->dev_start_doit = 0;
if (ret)
kfree(ctx->phy_req_info);
+ if (ctx->phy_req_info->base.dev)
+ ctx->phy_req_info->dev_start_doit = 1;
+
return ret;
}
@@ -234,7 +242,7 @@ int ethnl_phy_done(struct netlink_callback *cb)
{
struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx;
- if (ctx->phy_req_info->base.dev)
+ if (ctx->phy_req_info->base.dev && ctx->phy_req_info->dev_start_doit == 1)
ethnl_parse_header_dev_put(&ctx->phy_req_info->base);
kfree(ctx->phy_req_info);
Powered by blists - more mailing lists