Skip to contentSkip to conversation

ceph: fix memory leakage in ceph_readdir

PATCH Superseded [email protected] 2 participants 3 messages Mar 1, 2022 Ceph client

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix memory leakage in ceph_readdir

From: Xiubo Li <[email protected]>

---
 fs/ceph/dir.c | 1 +
 1 file changed, 1 insertion(+)
fs/ceph/dir.c +1 -0
index 0cf6afe283e9..6184cf123fa2 100644
@@ -521,6 +521,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 			      ceph_present_ino(inode->i_sb, le64_to_cpu(rde->inode.in->ino)),
 			      le32_to_cpu(rde->inode.in->mode) >> 12)) {
 			dout("filldir stopping us...\n");
+			ceph_mdsc_put_request(dfi->last_readdir);
 			return 0;
 		}
 		ctx->pos++;
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · On Tue, 2022-03-01 at 13:59 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

---
 fs/ceph/dir.c | 1 +
 1 file changed, 1 insertion(+)
fs/ceph/dir.c +0 -0
index 0cf6afe283e9..6184cf123fa2 100644

fs/ceph/dir.c static int ceph_readdir(struct file *file, struct dir_context *ctx) · line 527

Quoted 7 lines
fs/ceph/dir.c +1 -0
@@ -521,6 +521,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 			      ceph_present_ino(inode->i_sb, le64_to_cpu(rde->inode.in->ino)),
 			      le32_to_cpu(rde->inode.in->mode) >> 12)) {
 			dout("filldir stopping us...\n");
+			ceph_mdsc_put_request(dfi->last_readdir);
 			return 0;
 		}
 		ctx->pos++;

Good catch!

It looks like there is another missing put around line 482 after the note_last_dentry call. Could you fix that one up in the same patch?

author
#2 lore raw
Quoted 22 lines · Jeff Layton
Quoted 12 lines · On Tue, 2022-03-01 at 13:59 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

---
  fs/ceph/dir.c | 1 +
  1 file changed, 1 insertion(+)
fs/ceph/dir.c +0 -0
index 0cf6afe283e9..6184cf123fa2 100644

fs/ceph/dir.c static int ceph_readdir(struct file *file, struct dir_context *ctx) · line 527

Quoted 7 lines
fs/ceph/dir.c +1 -0
@@ -521,6 +521,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
  			      ceph_present_ino(inode->i_sb, le64_to_cpu(rde->inode.in->ino)),
  			      le32_to_cpu(rde->inode.in->mode) >> 12)) {
  			dout("filldir stopping us...\n");
+			ceph_mdsc_put_request(dfi->last_readdir);
  			return 0;
  		}
  		ctx->pos++;

Good catch!

Quoted 3 lines

It looks like there is another missing put around line 482 after the note_last_dentry call. Could you fix that one up in the same patch?

Sure. Will fix it.

- Xiubo

Quoted 2 lines