[PATCH v3 20/32] common/cnxk: access valid pass value

Nithin Dabilpuram ndabilpuram at marvell.com
Thu May 25 11:58:52 CEST 2023


From: Hanumanth Pothula <hpothula at marvell.com>

There is a possibility of accessing an invalid pass value on
rvu device look up failure, as the return value is dropped.

Hence pass through the return value of rvu device look, to make
sure valid pass value is accessed.

Signed-off-by: Hanumanth Pothula <hpothula at marvell.com>
---
 drivers/common/cnxk/roc_model.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/common/cnxk/roc_model.c b/drivers/common/cnxk/roc_model.c
index f4f2a38e70..6dc2afe7f0 100644
--- a/drivers/common/cnxk/roc_model.c
+++ b/drivers/common/cnxk/roc_model.c
@@ -148,6 +148,7 @@ cn10k_part_pass_get(uint32_t *part, uint32_t *pass)
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 	char dirname[PATH_MAX];
 	struct dirent *e;
+	int ret = -1;
 	DIR *dir;
 
 	dir = opendir(SYSFS_PCI_DEVICES);
@@ -165,18 +166,19 @@ cn10k_part_pass_get(uint32_t *part, uint32_t *pass)
 			 e->d_name);
 
 		/* Lookup for rvu device and get part pass information */
-		if (!rvu_device_lookup(dirname, part, pass))
+		ret = rvu_device_lookup(dirname, part, pass);
+		if (!ret)
 			break;
 	}
 
 	closedir(dir);
-	return 0;
+	return ret;
 }
 
 static bool
 populate_model(struct roc_model *model, uint32_t midr)
 {
-	uint32_t impl, major, part, minor, pass;
+	uint32_t impl, major, part, minor, pass = 0;
 	bool found = false;
 	size_t i;
 
-- 
2.25.1



More information about the dev mailing list