Skip to contentSkip to conversation

ceph: Silence a checker warning on the error path

PATCH Applied Dan Carpenter 2 participants 2 messages May 9, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: Silence a checker warning on the error path

The problem is that if ceph_mdsc_build_path() fails then we set "path" to NULL and the "pathlen" variable is uninitialized. The we call ceph_mdsc_free_path(path, pathlen) to clean up. Since "path" is NULL, the function is a no-op but Smatch and UBSan still complain that "pathlen" is uninitialized.

This patch doesn't change run time, it just silence the warnings.

---
 fs/ceph/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/debugfs.c +1 -1
index b3fc5fe26a1a..a14d64664878 100644
@@ -52,7 +52,7 @@ static int mdsc_show(struct seq_file *s, void *p)
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	struct rb_node *rp;
-	int pathlen;
+	int pathlen = 0;
 	u64 pathbase;
 	char *path;
 
Signature · 1 line
2.18.0
maintainer Applied
#1 lore raw
Quoted 19 lines · Dan Carpenter

The problem is that if ceph_mdsc_build_path() fails then we set "path" to NULL and the "pathlen" variable is uninitialized. The we call ceph_mdsc_free_path(path, pathlen) to clean up. Since "path" is NULL, the function is a no-op but Smatch and UBSan still complain that "pathlen" is uninitialized.

This patch doesn't change run time, it just silence the warnings.

---
 fs/ceph/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/debugfs.c +0 -0
index b3fc5fe26a1a..a14d64664878 100644

fs/ceph/debugfs.c static int mdsc_show(struct seq_file *s, void *p) · line 58

Quoted 8 lines
fs/ceph/debugfs.c +1 -1
@@ -52,7 +52,7 @@ static int mdsc_show(struct seq_file *s, void *p)
        struct ceph_mds_client *mdsc = fsc->mdsc;
        struct ceph_mds_request *req;
        struct rb_node *rp;
-       int pathlen;
+       int pathlen = 0;
        u64 pathbase;
        char *path;
 

Applied.

Thanks,

Ilya