Skip to content

Commit 7bd897c

Browse files
Dan Carpenteraxboe
authored andcommitted
block: fix an error code in add_partition()
We don't set an error code on this path. It means that we return NULL instead of an error pointer and the caller does a NULL dereference. Fixes: 6d1d805 ("block, partition: add partition_meta_info to hd_struct") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent b4f428e commit 7bd897c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

block/partition-generic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
320320

321321
if (info) {
322322
struct partition_meta_info *pinfo = alloc_part_info(disk);
323-
if (!pinfo)
323+
if (!pinfo) {
324+
err = -ENOMEM;
324325
goto out_free_stats;
326+
}
325327
memcpy(pinfo, info, sizeof(*info));
326328
p->info = pinfo;
327329
}

0 commit comments

Comments
 (0)