diff mbox series

[iproute2] devlink: always check strslashrsplit() return value

Message ID 09890143926c494e1cc3939a84eded4c55c27d9e.1618350667.git.aclaudi@redhat.com
State New
Headers show
Series [iproute2] devlink: always check strslashrsplit() return value | expand

Commit Message

Andrea Claudi April 13, 2021, 10:48 p.m. UTC
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>
---
 devlink/devlink.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/devlink/devlink.c b/devlink/devlink.c
index c6e85ff9..faa87b3d 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -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;
 }