btrfs-progs: fix double free on error in read_raid56()
Reported by 'gcc -fanalyzer': kernel-shared/extent_io.c: In function ‘read_raid56’: ./include/kerncompat.h:393:18: warning: dereference of NULL ‘pointers’ [CWE-476] [-Wanalyzer-null-dereference] After allocation of the pointers array fails it's dereferenced in the exit block. We can return immediately instead. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
2bdb838d54
commit
844caf8639
|
@ -339,10 +339,9 @@ static int read_raid56(struct btrfs_fs_info *fs_info, void *buf, u64 logical,
|
||||||
ASSERT(len <= BTRFS_STRIPE_LEN);
|
ASSERT(len <= BTRFS_STRIPE_LEN);
|
||||||
|
|
||||||
pointers = calloc(num_stripes, sizeof(void *));
|
pointers = calloc(num_stripes, sizeof(void *));
|
||||||
if (!pointers) {
|
if (!pointers)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
/* Allocate memory for the full stripe */
|
/* Allocate memory for the full stripe */
|
||||||
for (i = 0; i < num_stripes; i++) {
|
for (i = 0; i < num_stripes; i++) {
|
||||||
pointers[i] = kmalloc(BTRFS_STRIPE_LEN, GFP_KERNEL);
|
pointers[i] = kmalloc(BTRFS_STRIPE_LEN, GFP_KERNEL);
|
||||||
|
|
Loading…
Reference in New Issue