devlink: Check return code of strslashrsplit()
This function shouldn't fail because all callers of __dl_argv_handle_port() make sure the passed string contains enough slashes already, but better make sure if this changes in future the function won't access uninitialized data. Signed-off-by: Phil Sutter <phil@nwl.cc>
This commit is contained in:
parent
84b6a3f4b5
commit
6e33f7b0f6
|
|
@ -526,18 +526,26 @@ static int __dl_argv_handle_port(char *str,
|
||||||
char **p_bus_name, char **p_dev_name,
|
char **p_bus_name, char **p_dev_name,
|
||||||
uint32_t *p_port_index)
|
uint32_t *p_port_index)
|
||||||
{
|
{
|
||||||
char *handlestr = handlestr;
|
char *handlestr;
|
||||||
char *portstr = portstr;
|
char *portstr;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
strslashrsplit(str, &handlestr, &portstr);
|
err = strslashrsplit(str, &handlestr, &portstr);
|
||||||
|
if (err) {
|
||||||
|
pr_err("Port identification \"%s\" is invalid\n", str);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
err = strtouint32_t(portstr, p_port_index);
|
err = strtouint32_t(portstr, p_port_index);
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_err("Port index \"%s\" is not a number or not within range\n",
|
pr_err("Port index \"%s\" is not a number or not within range\n",
|
||||||
portstr);
|
portstr);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
strslashrsplit(handlestr, p_bus_name, p_dev_name);
|
err = strslashrsplit(handlestr, p_bus_name, p_dev_name);
|
||||||
|
if (err) {
|
||||||
|
pr_err("Port identification \"%s\" is invalid\n", str);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue