Static analyzer reported a possible NULL pointer dereference: - In main(), 'argp' is dereferenced and passed to find_option() without checking if *argp is NULL. - The function find_option() does not validate its input argument, which may lead to undefined behavior when using strncmp() or strcspn() with a NULL pointer. This patch adds proper NULL check in find_option() to prevent invalid memory access. Additionally, it improves robustness by making sure that the input argument is valid before passing it to find_option(). Found by Svace static analysis tool. Signed-off-by: Anton Moryakov --- ethtool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ethtool.c b/ethtool.c index 0513a1a..4250add 100644 --- a/ethtool.c +++ b/ethtool.c @@ -6395,6 +6395,9 @@ static int show_usage(struct cmd_context *ctx __maybe_unused) static int find_option(char *arg) { + if(!arg) + return -1; + const char *opt; size_t len; int k; -- 2.39.2