diff options
author | Andrew Lunn <andrew@lunn.ch> | 2020-07-17 00:05:09 +0200 |
---|---|---|
committer | Michal Kubecek <mkubecek@suse.cz> | 2020-07-19 22:45:17 +0200 |
commit | 0d0efc904a16bd57bccfb7527df7d8bca898abb2 (patch) | |
tree | 5a06e4200102fe5ae5a1a09a1e445aae224c9cc0 | |
parent | 44b782bce4bc0b41244ad4b0a3c42bc52a70037b (diff) | |
download | ethtool-0d0efc904a16bd57bccfb7527df7d8bca898abb2.tar.gz |
Fix segfault with cable test and ./configure --disable-netlink
When the netlink interface code is disabled, a stub version of
netlink_run_handler() is used. This stub version needs to handle the
case when there is no possibility for a command to fall back to the
IOCTL call. The two cable tests commands have no such fallback, and if
we don't handle this, ethtool tries to jump through a NULL pointer
resulting in a segfault.
Reported-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
-rw-r--r-- | netlink/extapi.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/netlink/extapi.h b/netlink/extapi.h index c5bfde9..a35d5f2 100644 --- a/netlink/extapi.h +++ b/netlink/extapi.h @@ -46,6 +46,12 @@ void nl_monitor_usage(void); static inline void netlink_run_handler(struct cmd_context *ctx, nl_func_t nlfunc, bool no_fallback) { + if (no_fallback) { + fprintf(stderr, + "Command requires kernel netlink support which is not " + "enabled in this ethtool binary\n"); + exit(1); + } } static inline int nl_monitor(struct cmd_context *ctx) |