diff mbox series

net/dcb: check for detached device before executing callbacks

Message ID 20240624134607.1701-1-dkirjanov@suse.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net/dcb: check for detached device before executing callbacks | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 842 this patch: 842
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 5 maintainers not CCed: pabeni@redhat.com edumazet@google.com kuba@kernel.org linma@zju.edu.cn horms@kernel.org
netdev/build_clang success Errors and warnings before: 849 this patch: 849
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 849 this patch: 849
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Denis Kirjanov <kirjanov@gmail.com>' != 'Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>' WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: 2f90b8657ec9 ("ixgbe: this patch adds support for DCB to the kernel and ixgbe driver")'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 5 this patch: 5
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-27--03-00 (tests: 665)

Commit Message

Denis Kirjanov June 24, 2024, 1:46 p.m. UTC
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")
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
---
 net/dcb/dcbnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Abeni June 27, 2024, 8:26 a.m. UTC | #1
Hi,

On Mon, 2024-06-24 at 09:46 -0400, Denis Kirjanov wrote:
> 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")
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>

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
diff mbox series

Patch

diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 2e6b8c8fd2de..80b3b6ba5d3c 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -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)