Skip to content

Commit

Permalink
block: fix an error code in add_partition()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Dan Carpenter authored and axboe committed May 23, 2017
1 parent b4f428e commit 7bd897c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion block/partition-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,

if (info) {
struct partition_meta_info *pinfo = alloc_part_info(disk);
if (!pinfo)
if (!pinfo) {
err = -ENOMEM;
goto out_free_stats;
}
memcpy(pinfo, info, sizeof(*info));
p->info = pinfo;
}
Expand Down

0 comments on commit 7bd897c

Please sign in to comment.