Skip to content

Commit a7be300

Browse files
committed
udf: Fix memory leak when mounting
udf_process_sequence() allocates temporary array for processing partition descriptors on volume which it fails to free. Free the array when it is not needed anymore. Fixes: 7b78fd0 ("udf: Fix handling of Partition Descriptors") CC: [email protected] Reported-by: [email protected] Signed-off-by: Jan Kara <[email protected]>
1 parent aa9f666 commit a7be300

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

fs/udf/super.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,8 @@ static noinline int udf_process_sequence(
16901690
"Pointers (max %u supported)\n",
16911691
UDF_MAX_TD_NESTING);
16921692
brelse(bh);
1693-
return -EIO;
1693+
ret = -EIO;
1694+
goto out;
16941695
}
16951696

16961697
vdp = (struct volDescPtr *)bh->b_data;
@@ -1710,7 +1711,8 @@ static noinline int udf_process_sequence(
17101711
curr = get_volume_descriptor_record(ident, bh, &data);
17111712
if (IS_ERR(curr)) {
17121713
brelse(bh);
1713-
return PTR_ERR(curr);
1714+
ret = PTR_ERR(curr);
1715+
goto out;
17141716
}
17151717
/* Descriptor we don't care about? */
17161718
if (!curr)
@@ -1732,28 +1734,31 @@ static noinline int udf_process_sequence(
17321734
*/
17331735
if (!data.vds[VDS_POS_PRIMARY_VOL_DESC].block) {
17341736
udf_err(sb, "Primary Volume Descriptor not found!\n");
1735-
return -EAGAIN;
1737+
ret = -EAGAIN;
1738+
goto out;
17361739
}
17371740
ret = udf_load_pvoldesc(sb, data.vds[VDS_POS_PRIMARY_VOL_DESC].block);
17381741
if (ret < 0)
1739-
return ret;
1742+
goto out;
17401743

17411744
if (data.vds[VDS_POS_LOGICAL_VOL_DESC].block) {
17421745
ret = udf_load_logicalvol(sb,
17431746
data.vds[VDS_POS_LOGICAL_VOL_DESC].block,
17441747
fileset);
17451748
if (ret < 0)
1746-
return ret;
1749+
goto out;
17471750
}
17481751

17491752
/* Now handle prevailing Partition Descriptors */
17501753
for (i = 0; i < data.num_part_descs; i++) {
17511754
ret = udf_load_partdesc(sb, data.part_descs_loc[i].rec.block);
17521755
if (ret < 0)
1753-
return ret;
1756+
goto out;
17541757
}
1755-
1756-
return 0;
1758+
ret = 0;
1759+
out:
1760+
kfree(data.part_descs_loc);
1761+
return ret;
17571762
}
17581763

17591764
/*

0 commit comments

Comments
 (0)