Skip to contentSkip to conversation

ceph: uninitialized variable in debug output

PATCH In review Dan Carpenter 4 participants 6 messages Mar 7, 2022 – Mar 8, 2022

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

PATCH 1/1 ceph: uninitialized variable in debug output

If read_mapping_folio() fails then "inline_version" is printed without being initialized.

Fixes 083db6fd3e73 ("ceph: uninline the data on a file opened for writing")
---
 fs/ceph/addr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/addr.c +2 -1
index 3c1257b09775..0d4120297ede 100644
@@ -1632,9 +1632,10 @@ int ceph_uninline_data(struct file *file)
 	struct ceph_osd_request *req;
 	struct ceph_cap_flush *prealloc_cf;
 	struct folio *folio = NULL;
+	u64 inline_version = -1;
 	struct page *pages[1];
-	u64 len, inline_version;
 	int err = 0;
+	u64 len;
 
 	prealloc_cf = ceph_alloc_cap_flush();
 	if (!prealloc_cf)
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Dan Carpenter

If read_mapping_folio() fails then "inline_version" is printed without being initialized.

Fixes 083db6fd3e73 ("ceph: uninline the data on a file opened for writing")
---
  fs/ceph/addr.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/addr.c +0 -0
index 3c1257b09775..0d4120297ede 100644
@@ -1632,9 +1632,10 @@ int ceph_uninline_data(struct file *file)
  	struct ceph_osd_request *req;

fs/ceph/addr.c int ceph_uninline_data(struct file *file) · line 1641

Quoted 10 lines
fs/ceph/addr.c +2 -1
  	struct ceph_cap_flush *prealloc_cf;
  	struct folio *folio = NULL;
+	u64 inline_version = -1;
  	struct page *pages[1];
-	u64 len, inline_version;
  	int err = 0;
+	u64 len;
 
  	prealloc_cf = ceph_alloc_cap_flush();
  	if (!prealloc_cf)

Possibly we'd better format the 'inline_version' in hexadecimal ?

#2 lore raw
In reply to Dan Carpenter

fs/ceph/addr.c int ceph_uninline_data(struct file *file) · line 1635

Quoted 1 line · Dan Carpenter
fs/ceph/addr.c +1 -0
+	u64 inline_version = -1;

ULLONG_MAX?

David

#3 lore raw
Quoted 8 lines · David Howells

fs/ceph/addr.c int ceph_uninline_data(struct file *file) · line 1635

Quoted 1 line · Dan Carpenter
fs/ceph/addr.c +1 -0
+	u64 inline_version = -1;

ULLONG_MAX?

David

...or maybe CEPH_INLINE_NONE, which is:

    #define CEPH_INLINE_NONE        ((__u64)-1)      
Signature · 1 line
Jeff Layton <[email protected]>
#4 lore raw
Quoted 7 lines · Jeff Layton
Quoted 6 lines · David Howells

fs/ceph/addr.c int ceph_uninline_data(struct file *file) · line 1635

Quoted 1 line · Dan Carpenter
fs/ceph/addr.c +1 -0
+	u64 inline_version = -1;

ULLONG_MAX?

Quoted 7 lines
Quoted 2 lines

David

...or maybe CEPH_INLINE_NONE, which is:

    #define CEPH_INLINE_NONE        ((__u64)-1)      

I went ahead and merged the patch into our testing branch, with the change to use CEPH_INLINE_NONE instead.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>
#5 lore raw
Quoted 11 lines · Jeff Layton
Quoted 10 lines · Jeff Layton
Quoted 8 lines · David Howells

fs/ceph/addr.c int ceph_uninline_data(struct file *file) · line 1635

Quoted 1 line · Dan Carpenter
fs/ceph/addr.c +1 -0
+	u64 inline_version = -1;

ULLONG_MAX?

David

Quoted 7 lines
Quoted 4 lines

...or maybe CEPH_INLINE_NONE, which is:

    #define CEPH_INLINE_NONE        ((__u64)-1)      

I went ahead and merged the patch into our testing branch, with the change to use CEPH_INLINE_NONE instead.

I liked CEPH_INLINE_NONE so I was resending it right now... But thanks!

regards,
dan carpenter