Message ID | 1459298791-32447-1-git-send-email-ming.lei@canonical.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> + if (err) { > + if (flags & ADDPART_FLAG_WHOLEDISK) > + goto out_remove_file; > + goto out_del; > + } I'd rather have that if around the actual device_remove_file at the label, and jump to out_remove_file unconditionally. Otherwise this looks fine to me. -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Mar 31, 2016 at 1:43 AM, Christoph Hellwig <hch@infradead.org> wrote: >> + if (err) { >> + if (flags & ADDPART_FLAG_WHOLEDISK) >> + goto out_remove_file; >> + goto out_del; >> + } > > I'd rather have that if around the actual device_remove_file at the > label, and jump to out_remove_file unconditionally. OK, looks better. > > Otherwise this looks fine to me. > -- > To unsubscribe from this list: send the line "unsubscribe linux-block" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/block/partition-generic.c b/block/partition-generic.c index 5d87019..84c53f0 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -361,15 +361,20 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, goto out_del; } + err = hd_ref_init(p); + if (err) { + if (flags & ADDPART_FLAG_WHOLEDISK) + goto out_remove_file; + goto out_del; + } + /* everything is up and running, commence */ rcu_assign_pointer(ptbl->part[partno], p); /* suppress uevent if the disk suppresses it */ if (!dev_get_uevent_suppress(ddev)) kobject_uevent(&pdev->kobj, KOBJ_ADD); - - if (!hd_ref_init(p)) - return p; + return p; out_free_info: free_part_info(p); @@ -378,6 +383,8 @@ out_free_stats: out_free: kfree(p); return ERR_PTR(err); +out_remove_file: + device_remove_file(pdev, &dev_attr_whole_disk); out_del: kobject_put(p->holder_dir); device_del(pdev);