mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-23 07:25:20 +00:00
btrfs-progs: free memory before error exit in read_whole_eb
Free the memory allocated to "multi" before the error exit in read_whole_eb(). Set it to NULL after we free it in the loop to avoid any potential double-free. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
This commit is contained in:
parent
d310e9cfff
commit
2e23e290ca
@ -198,17 +198,21 @@ static int read_whole_eb(struct btrfs_fs_info *info, struct extent_buffer *eb, i
|
|||||||
mirror, NULL);
|
mirror, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk("Couldn't map the block %Lu\n", eb->start + offset);
|
printk("Couldn't map the block %Lu\n", eb->start + offset);
|
||||||
|
kfree(multi);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
device = multi->stripes[0].dev;
|
device = multi->stripes[0].dev;
|
||||||
|
|
||||||
if (device->fd == 0)
|
if (device->fd == 0) {
|
||||||
|
kfree(multi);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
eb->fd = device->fd;
|
eb->fd = device->fd;
|
||||||
device->total_ios++;
|
device->total_ios++;
|
||||||
eb->dev_bytenr = multi->stripes[0].physical;
|
eb->dev_bytenr = multi->stripes[0].physical;
|
||||||
kfree(multi);
|
kfree(multi);
|
||||||
|
multi = NULL;
|
||||||
|
|
||||||
if (read_len > bytes_left)
|
if (read_len > bytes_left)
|
||||||
read_len = bytes_left;
|
read_len = bytes_left;
|
||||||
|
Loading…
Reference in New Issue
Block a user