Skip to contentSkip to conversation

raw/ifpga: initialize scalar variable before using

PATCH Superseded Wei Huang 4 participants 8 messages Feb 18, 2022 – Mar 7, 2022

lore
Share & tools
lore

Wei Huang

author
#0 lore raw

PATCH 1/1 raw/ifpga: initialize scalar variable before using

Scalar variable sub_brg_bdf may be used uninitialized in function ifpga_rawdev_fill_info(), this fix initialize it.

Fixes 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")
---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
index b73512d..b02eb23 100644
@@ -216,7 +216,7 @@ static int ifpga_rawdev_fill_info(struct ifpga_rawdev *ifpga_dev,
 	char dir[1024] = "/sys/devices/";
 	char *c;
 	int ret;
-	char sub_brg_bdf[4][16];
+	char sub_brg_bdf[4][16] = {{0},{0},{0},{0}};
 	int point;
 	DIR *dp = NULL;
 	struct dirent *entry;
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH v2 1/1 raw/ifpga: initialize scalar variable before using

Scalar variable sub_brg_bdf may be used uninitialized in function ifpga_rawdev_fill_info(), this fix initialize it.

Fixes 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")

---
v2: add space after comma to meet coding style requirement

---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
index b73512d..c133a94 100644
@@ -216,7 +216,7 @@ static int ifpga_rawdev_fill_info(struct ifpga_rawdev *ifpga_dev,
 	char dir[1024] = "/sys/devices/";
 	char *c;
 	int ret;
-	char sub_brg_bdf[4][16];
+	char sub_brg_bdf[4][16] = {{0}, {0}, {0}, {0}};
 	int point;
 	DIR *dp = NULL;
 	struct dirent *entry;
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH v3 1/1 raw/ifpga: initialize scalar variable before using

Scalar variable sub_brg_bdf may be used uninitialized in function ifpga_rawdev_fill_info(). It is initialized now in this fix.

Fixes 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")

---
v2: add space after comma to meet coding style requirement
---
v3: refine log

---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
index b73512d..c133a94 100644
@@ -216,7 +216,7 @@ static int ifpga_rawdev_fill_info(struct ifpga_rawdev *ifpga_dev,
 	char dir[1024] = "/sys/devices/";
 	char *c;
 	int ret;
-	char sub_brg_bdf[4][16];
+	char sub_brg_bdf[4][16] = {{0}, {0}, {0}, {0}};
 	int point;
 	DIR *dp = NULL;
 	struct dirent *entry;
Signature · 1 line
1.8.3.1
Acked-by on v3 1/1
#3 lore raw

Hi,

Quoted 38 lines

-----Original Message-----
From: Huang, Wei <[email protected]>
Sent: Monday, February 21, 2022 10:20
To: [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Zhang, Tianfei <[email protected]>; Yigit, Ferruh <[email protected]>; Huang, Wei <[email protected]>
Subject: [PATCH v3] raw/ifpga: initialize scalar variable before using

Scalar variable sub_brg_bdf may be used uninitialized in function ifpga_rawdev_fill_info(). It is initialized now in this fix.

Fixes 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")

---
v2: add space after comma to meet coding style requirement
---
v3: refine log

---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
index b73512d..c133a94 100644
@@ -216,7 +216,7 @@ static int ifpga_rawdev_fill_info(struct ifpga_rawdev
 *ifpga_dev,
 	char dir[1024] = "/sys/devices/";
 	char *c;
 	int ret;
-	char sub_brg_bdf[4][16];
+	char sub_brg_bdf[4][16] = {{0}, {0}, {0}, {0}};
 	int point;
 	DIR *dp = NULL;
Quoted 3 lines

struct dirent *entry;
--
1.8.3.1

author
#4 lore raw

PATCH v4 1/1 raw/ifpga: initialize scalar variable before using

In reply to Wei Huang

Scalar variable sub_brg_bdf may be used uninitialized in function ifpga_rawdev_fill_info(). It is initialized now in this fix.

Coverity issue: 375805

Fixes 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")

---
v2: add space after comma to meet coding style requirement
---
v3: refine log
---
v4: add coverity issue id

---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
index b73512d..c133a94 100644
@@ -216,7 +216,7 @@ static int ifpga_rawdev_fill_info(struct ifpga_rawdev *ifpga_dev,
 	char dir[1024] = "/sys/devices/";
 	char *c;
 	int ret;
-	char sub_brg_bdf[4][16];
+	char sub_brg_bdf[4][16] = {{0}, {0}, {0}, {0}};
 	int point;
 	DIR *dp = NULL;
 	struct dirent *entry;
Signature · 1 line
1.8.3.1
author
#5 lore raw

PATCH v5 1/1 raw/ifpga: initialize scalar variable before using

Scalar variable sub_brg_bdf may be used uninitialized in function ifpga_rawdev_fill_info(). It is initialized now in this fix.

Coverity issue: 375805

Fixes 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")

---
v2: add space after comma to meet coding style requirement
---
v3: refine log
---
v4: add coverity issue id
---
v5: use simple initializer

---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
index b73512d..6beecb7 100644
@@ -216,7 +216,7 @@ static int ifpga_rawdev_fill_info(struct ifpga_rawdev *ifpga_dev,
 	char dir[1024] = "/sys/devices/";
 	char *c;
 	int ret;
-	char sub_brg_bdf[4][16];
+	char sub_brg_bdf[4][16] = {{0}};
 	int point;
 	DIR *dp = NULL;
 	struct dirent *entry;
Signature · 1 line
1.8.3.1
Acked-by on v5 1/1
#6 lore raw
Quoted 45 lines

-----Original Message-----
From: Huang, Wei <[email protected]>
Sent: Monday, February 21, 2022 3:52 PM
To: [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Zhang, Tianfei <[email protected]>; Yigit, Ferruh <[email protected]>; Huang, Wei <[email protected]>
Subject: [PATCH v5] raw/ifpga: initialize scalar variable before using

Scalar variable sub_brg_bdf may be used uninitialized in function ifpga_rawdev_fill_info(). It is initialized now in this fix.

Coverity issue: 375805

Fixes 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")

---
v2: add space after comma to meet coding style requirement
---
v3: refine log
---
v4: add coverity issue id
---
v5: use simple initializer

---
 drivers/raw/ifpga/ifpga_rawdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/raw/ifpga/ifpga_rawdev.c +1 -1
index b73512d..6beecb7 100644
@@ -216,7 +216,7 @@ static int ifpga_rawdev_fill_info(struct ifpga_rawdev
 *ifpga_dev,
 	char dir[1024] = "/sys/devices/";
 	char *c;
 	int ret;
-	char sub_brg_bdf[4][16];
+	char sub_brg_bdf[4][16] = {{0}};
 	int point;
 	DIR *dp = NULL;
Quoted 2 lines

struct dirent *entry;
--

It looks good for me.

Quoted 1 line

1.8.3.1

#7 lore raw

28/02/2022 08:58, Zhang, Tianfei:

Quoted 15 lines

From: Huang, Wei <[email protected]>

Quoted 14 lines

Sent: Monday, February 21, 2022 3:52 PM
To: [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Zhang, Tianfei <[email protected]>; Yigit, Ferruh <[email protected]>; Huang, Wei <[email protected]>
Subject: [PATCH v5] raw/ifpga: initialize scalar variable before using

Scalar variable sub_brg_bdf may be used uninitialized in function ifpga_rawdev_fill_info(). It is initialized now in this fix.

Coverity issue: 375805

Fixes 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")
Quoted 5 lines
Quoted 1 line

It looks good for me.

Applied, thanks.