Skip to contentSkip to conversation

block: partition-generic: Catch alloc_part_info failure

PATCH New Axel Lin 1 participant 1 message Jun 23, 2015 Block layer

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 block: partition-generic: Catch alloc_part_info failure

Make add_partition() return proper ERR_PTR if alloc_part_info() fails. This ensures the caller of add_partition() can catch the error by IS_ERROR macro.

---
 block/partition-generic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/partition-generic.c +3 -1
index 0d9e5f9..94de205 100644
@@ -309,8 +309,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;
 	}
Signature · 7 lines
2.1.0



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/