lkml.org 
[lkml]   [2020]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Linux-kernel-mentees] [PATCH] udf: Fix memory leak in udf_process_sequence()
Date
udf_process_sequence() is leaking memory. Free `data.part_descs_loc`
before returning.

Cc: stable@vger.kernel.org
Fixes: 7b78fd02fb19 ("udf: Fix handling of Partition Descriptors")
Reported-and-tested-by: syzbot+128f4dd6e796c98b3760@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=c5ec4e6f5d818f3c4afd4d59342468eec08a38da
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
---
fs/udf/super.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 1c42f544096d..b0d862ab3024 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1698,7 +1698,8 @@ static noinline int udf_process_sequence(
"Pointers (max %u supported)\n",
UDF_MAX_TD_NESTING);
brelse(bh);
- return -EIO;
+ ret = -EIO;
+ goto out;
}

vdp = (struct volDescPtr *)bh->b_data;
@@ -1718,7 +1719,8 @@ static noinline int udf_process_sequence(
curr = get_volume_descriptor_record(ident, bh, &data);
if (IS_ERR(curr)) {
brelse(bh);
- return PTR_ERR(curr);
+ ret = PTR_ERR(curr);
+ goto out;
}
/* Descriptor we don't care about? */
if (!curr)
@@ -1740,28 +1742,32 @@ static noinline int udf_process_sequence(
*/
if (!data.vds[VDS_POS_PRIMARY_VOL_DESC].block) {
udf_err(sb, "Primary Volume Descriptor not found!\n");
- return -EAGAIN;
+ ret = -EAGAIN;
+ goto out;
}
ret = udf_load_pvoldesc(sb, data.vds[VDS_POS_PRIMARY_VOL_DESC].block);
if (ret < 0)
- return ret;
+ goto out;

if (data.vds[VDS_POS_LOGICAL_VOL_DESC].block) {
ret = udf_load_logicalvol(sb,
data.vds[VDS_POS_LOGICAL_VOL_DESC].block,
fileset);
if (ret < 0)
- return ret;
+ goto out;
}

/* Now handle prevailing Partition Descriptors */
for (i = 0; i < data.num_part_descs; i++) {
ret = udf_load_partdesc(sb, data.part_descs_loc[i].rec.block);
if (ret < 0)
- return ret;
+ goto out;
}

- return 0;
+ ret = 0;
+out:
+ kfree(data.part_descs_loc);
+ return ret;
}

/*
--
2.25.1
\
 
 \ /
  Last update: 2020-09-22 17:47    [W:0.052 / U:11.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site