Skip to content

Commit

Permalink
ubifs: mount_ubifs: Release authentication resource in error handling…
Browse files Browse the repository at this point in the history
… path

commit e2a05cc upstream.

Release the authentication related resource in some error handling
branches in mount_ubifs().

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: <stable@vger.kernel.org>  # 4.20+
Fixes: d8a2277 ("ubifs: Enable authentication support")
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Zhihao Cheng authored and gregkh committed Nov 5, 2020
1 parent 9ba6324 commit a99cbd2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/ubifs/super.c
Expand Up @@ -1313,7 +1313,7 @@ static int mount_ubifs(struct ubifs_info *c)

err = ubifs_read_superblock(c);
if (err)
goto out_free;
goto out_auth;

c->probing = 0;

Expand All @@ -1325,18 +1325,18 @@ static int mount_ubifs(struct ubifs_info *c)
ubifs_err(c, "'compressor \"%s\" is not compiled in",
ubifs_compr_name(c, c->default_compr));
err = -ENOTSUPP;
goto out_free;
goto out_auth;
}

err = init_constants_sb(c);
if (err)
goto out_free;
goto out_auth;

sz = ALIGN(c->max_idx_node_sz, c->min_io_size) * 2;
c->cbuf = kmalloc(sz, GFP_NOFS);
if (!c->cbuf) {
err = -ENOMEM;
goto out_free;
goto out_auth;
}

err = alloc_wbufs(c);
Expand Down Expand Up @@ -1611,6 +1611,8 @@ static int mount_ubifs(struct ubifs_info *c)
free_wbufs(c);
out_cbuf:
kfree(c->cbuf);
out_auth:
ubifs_exit_authentication(c);
out_free:
kfree(c->write_reserve_buf);
kfree(c->bu.buf);
Expand Down

0 comments on commit a99cbd2

Please sign in to comment.