]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: always check strslashrsplit() return value
authorAndrea Claudi <aclaudi@redhat.com>
Tue, 13 Apr 2021 22:48:37 +0000 (00:48 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 14 Apr 2021 02:16:55 +0000 (19:16 -0700)
strslashrsplit() return value is not checked in __dl_argv_handle(),
despite the fact that it can return EINVAL.

This commit fix it and make __dl_argv_handle() return error if
strslashrsplit() return an error code.

Fixes: 2f85a9c53587 ("devlink: allow to parse both devlink and port handle in the same time")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
devlink/devlink.c

index c6e85ff97a7ae28d94b3e52d21ba0b553394ef78..faa87b3def678613c1a9270ea2a510faf23b8951 100644 (file)
@@ -965,7 +965,13 @@ static int strtobool(const char *str, bool *p_val)
 
 static int __dl_argv_handle(char *str, char **p_bus_name, char **p_dev_name)
 {
-       strslashrsplit(str, p_bus_name, p_dev_name);
+       int err;
+
+       err = strslashrsplit(str, p_bus_name, p_dev_name);
+       if (err) {
+               pr_err("Devlink identification (\"bus_name/dev_name\") \"%s\" is invalid\n", str);
+               return err;
+       }
        return 0;
 }