md/raid5: don't index beyond end of array in need_this_block().
[firefly-linux-kernel-4.4.55.git] / block / genhd.c
index 85df45292dbaf97bc94e6bc7cd18380343c17928..0c706f33a599a723fc56b0ef87bb58a71de2cd66 100644 (file)
@@ -1284,7 +1284,11 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
                 * converted to make use of bd_mutex and sequence counters.
                 */
                seqcount_init(&disk->part0.nr_sects_seq);
-               hd_ref_init(&disk->part0);
+               if (hd_ref_init(&disk->part0)) {
+                       hd_free_part(&disk->part0);
+                       kfree(disk);
+                       return NULL;
+               }
 
                disk->minors = minors;
                rand_initialize_disk(disk);