]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: devlink: skip info_get op call if it is not defined in dumpit
authorJiri Pirko <jiri@mellanox.com>
Sat, 23 Mar 2019 23:21:03 +0000 (00:21 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Mar 2019 18:25:29 +0000 (11:25 -0700)
In dumpit, unlike doit, the check for info_get op being defined
is missing. Add it and avoid null pointer dereference in case driver
does not define this op.

Fixes: f9cf22882c60 ("devlink: add device information API")
Reported-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/devlink.c

index 78e22cea4cc79589e22781849a843397904e220c..da0a29f30885d1f54b975ecfa4f83b47c68be543 100644 (file)
@@ -3897,6 +3897,11 @@ static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg,
                        continue;
                }
 
+               if (!devlink->ops->info_get) {
+                       idx++;
+                       continue;
+               }
+
                mutex_lock(&devlink->lock);
                err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET,
                                           NETLINK_CB(cb->skb).portid,