Skip to content

Commit 6bc40e4

Browse files
committed
Merge tag 'ovl-fixes-6.7-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs
Pull overlayfs fixes from Amir Goldstein: "A fix to an overlayfs param parsing bug and a misformatted comment" * tag 'ovl-fixes-6.7-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs: ovl: fix memory leak in ovl_parse_param() ovl: fix misformatted comment
2 parents eb9a643 + 37f32f5 commit 6bc40e4

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

fs/overlayfs/params.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
430430
struct ovl_fs_context *ctx = fc->fs_private;
431431
struct ovl_fs_context_layer *l;
432432
char *dup = NULL, *iter;
433-
ssize_t nr_lower = 0, nr = 0, nr_data = 0;
433+
ssize_t nr_lower, nr;
434434
bool data_layer = false;
435435

436436
/*
@@ -482,6 +482,7 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
482482
iter = dup;
483483
l = ctx->lower;
484484
for (nr = 0; nr < nr_lower; nr++, l++) {
485+
ctx->nr++;
485486
memset(l, 0, sizeof(*l));
486487

487488
err = ovl_mount_dir(iter, &l->path);
@@ -498,10 +499,10 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
498499
goto out_put;
499500

500501
if (data_layer)
501-
nr_data++;
502+
ctx->nr_data++;
502503

503504
/* Calling strchr() again would overrun. */
504-
if ((nr + 1) == nr_lower)
505+
if (ctx->nr == nr_lower)
505506
break;
506507

507508
err = -EINVAL;
@@ -511,7 +512,7 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
511512
* This is a regular layer so we require that
512513
* there are no data layers.
513514
*/
514-
if ((ctx->nr_data + nr_data) > 0) {
515+
if (ctx->nr_data > 0) {
515516
pr_err("regular lower layers cannot follow data lower layers");
516517
goto out_put;
517518
}
@@ -524,8 +525,6 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
524525
data_layer = true;
525526
iter++;
526527
}
527-
ctx->nr = nr_lower;
528-
ctx->nr_data += nr_data;
529528
kfree(dup);
530529
return 0;
531530

fs/overlayfs/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ int ovl_set_protattr(struct inode *inode, struct dentry *upper,
978978
return 0;
979979
}
980980

981-
/**
981+
/*
982982
* Caller must hold a reference to inode to prevent it from being freed while
983983
* it is marked inuse.
984984
*/

0 commit comments

Comments
 (0)