Skip to contentSkip to conversation

net/dcb: check for detached device before executing callbacks

PATCH In review Denis Kirjanov 2 participants 2 messages Jun 24, 2024 – Jun 27, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/dcb: check for detached device before executing callbacks

When a netdevice is detached there is no point in trying to execute the dcb callbacks; at best they will return stale information, and at worst crash the machine.

Fixes 2f90b8657ec94 ("ixgbe: this patch adds support for DCB to the kernel and ixgbe driver")
---
 net/dcb/dcbnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/dcb/dcbnl.c +1 -1
index 2e6b8c8fd2de..80b3b6ba5d3c 100644
@@ -1943,7 +1943,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
 		return -EINVAL;
 
 	netdev = __dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME]));
-	if (!netdev)
+	if (!netdev || !netif_device_present(netdev))
 		return -ENODEV;
 
 	if (!netdev->dcbnl_ops)
Signature · 1 line
2.30.2
maintainer
#1 lore raw

Hi,

Quoted 7 lines · Denis Kirjanov

When a netdevice is detached there is no point in trying to execute the dcb callbacks; at best they will return stale information, and at worst crash the machine.

Fixes 2f90b8657ec94 ("ixgbe: this patch adds support for DCB to the kernel and ixgbe driver")

The patch LGTM, but please fix the patch sender to match the patch author to make checkpatch happy.

./scripts/checkpatch.pl --strict --git HEAD^..

before the submission is your friend:)

Also please add the target tree ('net') in the subj prefix when you will submit the next revision.

Thanks!

Paolo