Skip to content

Commit

Permalink
udf: Fix memory leak when mounting
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jankara committed Sep 22, 2020
1 parent aa9f666 commit a7be300
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions fs/udf/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,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;
Expand All @@ -1710,7 +1711,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)
Expand All @@ -1732,28 +1734,31 @@ 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;
}

/*
Expand Down

0 comments on commit a7be300

Please sign in to comment.