mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Dirk Hohndel <hohndel@linux.intel.com>
Cc: Andries Brouwer <aeb@cwi.nl>, Al Viro <viro@ftp.linux.org.uk>,
	Jens Axboe <jens.axboe@oracle.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] add_partition silently ignored errors
Date: Mon, 29 Oct 2007 14:06:57 +0100	[thread overview]
Message-ID: <20071029140657.09d3a343@gondolin.boeblingen.de.ibm.com> (raw)
In-Reply-To: <20071029122211.GA18536@bigserver.hohndel.org>

On Mon, 29 Oct 2007 05:22:11 -0700,
Dirk Hohndel <hohndel@linux.intel.com> wrote:

<only commenting on the kobject part...>

> @@ -390,20 +390,31 @@ 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)) 
> +		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")) {
> +		kobject_del(&p->kobj);
> +		kfree(p);
> +		return -1;
> +	}


- This is missing a KOBJ_DEL uevent if you did a KOBJ_ADD uevent.
- Calling kfree() after you already registered the kobject via
  kobject_add() is wrong, since someone else might already have obtained
  a reference. You must drop your reference after kobject_del() and let
  the release mechanism take care of it.

<I think I'm having some kind of deja vu, since it seems I've already
pointed that out a couple of times to different people :) >

>  	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)) {
> +			kobject_del(&p->kobj);
> +			kfree(p);
> +			return -1;
> +		}

Same here. You should probably also delete the link you created above.

>  	}
>  	partition_sysfs_add_subdir(p);
>  	disk->part[part-1] = p;
> +	
> +	return 0;
>  }
> 
>  static char *make_block_name(struct gendisk *disk)

  reply	other threads:[~2007-10-29 13:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-29 12:22 Dirk Hohndel
2007-10-29 13:06 ` Cornelia Huck [this message]
2007-10-29 14:24   ` Dirk Hohndel
2007-10-29 14:43     ` Cornelia Huck
2007-10-29 15:48       ` Dirk Hohndel
2007-10-29 16:47         ` Cornelia Huck
2007-10-30  8:07         ` Jens Axboe
2007-10-30  9:09           ` Cornelia Huck
2007-10-30 16:56             ` Dirk Hohndel
2007-10-30 17:31               ` Cornelia Huck
2007-10-30 22:56                 ` Dirk Hohndel
2007-10-31  9:45                   ` Cornelia Huck
2007-11-02 13:04                   ` Jens Axboe
2007-11-02 19:29                     ` Dirk Hohndel
2007-11-02 19:50                       ` Bob Copeland
2007-11-02 20:29                         ` Dirk Hohndel
2007-11-06 20:02                           ` [PATCH] FS: " Dirk Hohndel
2007-11-06 21:38                             ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071029140657.09d3a343@gondolin.boeblingen.de.ibm.com \
    --to=cornelia.huck@de.ibm.com \
    --cc=aeb@cwi.nl \
    --cc=hohndel@linux.intel.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®