[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20071029154339.00512901@gondolin.boeblingen.de.ibm.com>
Date: Mon, 29 Oct 2007 15:43:39 +0100
From: Cornelia Huck <cornelia.huck@...ibm.com>
To: Dirk Hohndel <hohndel@...ux.intel.com>
Cc: Andries Brouwer <aeb@....nl>, Al Viro <viro@....linux.org.uk>,
Jens Axboe <jens.axboe@...cle.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] add_partition silently ignored errors
On Mon, 29 Oct 2007 07:24:27 -0700,
Dirk Hohndel <hohndel@...ux.intel.com> wrote:
> @@ -390,20 +390,33 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
> p->kobj.parent = &disk->kobj;
> p->kobj.ktype = &ktype_part;
> kobject_init(&p->kobj);
> - kobject_add(&p->kobj);
> + if (kobject_add(&p->kobj))
Hm, here the structure needs to be freed as well (via kobject_put()).
> + return -1;
> if (!disk->part_uevent_suppress)
> kobject_uevent(&p->kobj, KOBJ_ADD);
> - sysfs_create_link(&p->kobj, &block_subsys.kobj, "subsystem");
> + if(sysfs_create_link(&p->kobj, &block_subsys.kobj, "subsystem"))
Whitespace (if (...)).
> + goto out_cleanup;
> if (flags & ADDPART_FLAG_WHOLEDISK) {
> static struct attribute addpartattr = {
> .name = "whole_disk",
> .mode = S_IRUSR | S_IRGRP | S_IROTH,
> };
>
> - sysfs_create_file(&p->kobj, &addpartattr);
> + if (sysfs_create_file(&p->kobj, &addpartattr)) {
> + sysfs_remove_link (&p->kobj, "subsystem");
> + goto out_cleanup;
> + }
> }
> partition_sysfs_add_subdir(p);
> disk->part[part-1] = p;
> +
> + return 0;
> +
> +out_cleanup:
> + if (!disk->part_uevent_suppress)
> + kobject_uevent(&p->kobj, KOBJ_REMOVE);
> + kobject_del(&p->kobj);
You need a kobject_put() here to drop the reference you obtained in
kobject_init().
> + return -1;
> }
>
> static char *make_block_name(struct gendisk *disk)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists