bus/platform: fix resource names iteration
PATCH 1/2 bus/platform: fix resource names iteration
Fix stop condition and make sure we have some
sentinel at the end of buffer to make sure
loop can properly terminate.
Coverity issue: 383661
Fixes 17c839f74da3 ("bus: add platform bus")
Signed-off-by Tomasz Duszynski <[email protected]>
--- drivers/bus/platform/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/platform/platform.c +2 -2
@@ -249,11 +249,11 @@ of_resource_name(const char *dev_name, int index)char *name;snprintf (path,sizeof (path),PLATFORM_BUS_DEVICES_PATH "/%s/of_node/reg-names" , dev_name); - ret =read_sysfs_string (path, buf,sizeof (buf)); + ret =read_sysfs_string (path, buf,sizeof (buf) -1 );if (ret)return NULL ; -for (name = buf; name; name +=strlen (name) +1 ) { +for (name = buf; *name !=0 ; name +=strlen (name) +1 ) {if (num++ != index)continue ;return strdup (name);
Signature · 1 line
2.34.1
PATCH 2/2 bus/platform: do not allow adding existing device
Do not allow adding the same device multiple times.
Coverity issue: 383663
Fixes 17c839f74da3 ("bus: add platform bus")
Signed-off-by Tomasz Duszynski <[email protected]>
--- drivers/bus/platform/platform.c | 1 + 1 file changed, 1 insertion(+)
drivers/bus/platform/platform.c +1 -0
@@ -103,6 +103,7 @@ dev_add(const char *dev_name)rte_devargs_remove (pdev->device.devargs);free (pdev); +return -EEXIST ; } }
Signature · 1 line
2.34.1
Re: [PATCH 2/2] bus/platform: do not allow adding existing device
16/03/2023 10:41, Tomasz Duszynski:
Quoted 6 lines
Do not allow adding the same device multiple times.
Coverity issue: 383663
Fixes 17c839f74da3 ("bus: add platform bus")Signed-off-by Tomasz Duszynski <[email protected]>
Series applied, thanks.