Skip to contentSkip to conversation

cxl/memdev: initialize 'rc' in action_update_fw()

PATCH In review Vishal Verma 2 participants 3 messages Jul 31, 2023 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 cxl/memdev: initialize 'rc' in action_update_fw()

Static analysis complains that in some cases, an uninitialized 'rc' can get returned from action_update_fw(). Since this can only happen in a 'no-op' case, initialize rc to 0.

---
 cxl/memdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cxl/memdev.c +1 -1
index 1ad871a..f6a2d3f 100644
@@ -679,7 +679,7 @@ static int action_update_fw(struct cxl_memdev *memdev,
 	const char *devname = cxl_memdev_get_devname(memdev);
 	struct json_object *jmemdev;
 	unsigned long flags;
-	int rc;
+	int rc = 0;
 
 	if (param.cancel)
 		return cxl_memdev_cancel_fw_update(memdev);

---
base-commit: 32cec0c5cfe669940107ce030beeb1e02e5a767b
change-id: 20230731-coverity-fix-edc28fd6e0fe

Best regards,

Signature · 1 line
Vishal Verma <[email protected]>
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Vishal Verma

Static analysis complains that in some cases, an uninitialized 'rc' can get returned from action_update_fw(). Since this can only happen in a 'no-op' case, initialize rc to 0.

Quoted 23 lines
---
  cxl/memdev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
cxl/memdev.c +1 -2
index 1ad871a..f6a2d3f 100644
@@ -679,7 +679,7 @@ static int action_update_fw(struct cxl_memdev *memdev,
  	const char *devname = cxl_memdev_get_devname(memdev);
  	struct json_object *jmemdev;
  	unsigned long flags;
-	int rc;
+	int rc = 0;
 
  	if (param.cancel)
  		return cxl_memdev_cancel_fw_update(memdev);
 
---

base-commit: 32cec0c5cfe669940107ce030beeb1e02e5a767b
change-id: 20230731-coverity-fix-edc28fd6e0fe

Best regards,

author maintainer
#2 lore raw
In reply to Vishal Verma
Quoted 5 lines · Vishal Verma

Static analysis complains that in some cases, an uninitialized 'rc' can get returned from action_update_fw(). Since this can only happen in a 'no-op' case, initialize rc to 0.

This should've included a

Fixes 64ad46b4a147 ("cxl: add an update-firmware command")

tag. I'll add it when applying.

Quoted 23 lines

---
 cxl/memdev.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
cxl/memdev.c +1 -1
index 1ad871a..f6a2d3f 100644
@@ -679,7 +679,7 @@ static int action_update_fw(struct cxl_memdev *memdev,
         const char *devname = cxl_memdev_get_devname(memdev);
         struct json_object *jmemdev;
         unsigned long flags;
-       int rc;
+       int rc = 0;


        if (param.cancel)
                return cxl_memdev_cancel_fw_update(memdev);

---
base-commit: 32cec0c5cfe669940107ce030beeb1e02e5a767b
change-id: 20230731-coverity-fix-edc28fd6e0fe

Best regards,