Skip to content

Commit

Permalink
UBIFS: Fix possible memory leak in ubifs_readdir()
Browse files Browse the repository at this point in the history
If ubifs_tnc_next_ent() returns something else than -ENOENT
we leak file->private_data.

Signed-off-by: Richard Weinberger <[email protected]>
Reviewed-by: David Gstir <[email protected]>
  • Loading branch information
richardweinberger committed Nov 6, 2015
1 parent 86ba9ed commit aeeb14f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/ubifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,14 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
}

out:
kfree(file->private_data);
file->private_data = NULL;

if (err != -ENOENT) {
ubifs_err(c, "cannot find next direntry, error %d", err);
return err;
}

kfree(file->private_data);
file->private_data = NULL;
/* 2 is a special value indicating that there are no more direntries */
ctx->pos = 2;
return 0;
Expand Down

0 comments on commit aeeb14f

Please sign in to comment.