mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Maneesh Soni <maneesh@in.ibm.com>
Cc: Andrew Morton <akpm@osdl.org>, Greg KH <greg@kroah.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/5] Add sysfs_dirent to sysfs dentry
Date: Tue, 3 Aug 2004 13:43:31 +0100	[thread overview]
Message-ID: <20040803124329.GS12308@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20040729203821.GC4592@in.ibm.com>

On Thu, Jul 29, 2004 at 03:38:21PM -0500, Maneesh Soni wrote:
> +			} else {
> +				/* error, release the ref taken in
> +				 * sysfs_create()
> +				 */
> +				dput(*d);  

Umm...  Shouldn't we unhash here?  sysfs_create() did hash it, so...
Same goes for other places where we fail to create sysfs_dirent; as
the matter of fact, how about making
	sysfs_make_dirent(dentry, mode, data, type)
that would either allocate sysfs_dirent and bind it to dentry, or
unhash and dput() dentry and return error?  AFAICS, that would make
life easier.

>  int sysfs_create_file(struct kobject * kobj, const struct attribute * attr)
>  {
> -	if (kobj && attr)
> -		return sysfs_add_file(kobj->dentry,attr);
> +	if (kobj && kobj->dentry && attr)
> +		return sysfs_add_file(kobj->dentry, attr, SYSFS_KOBJ_ATTR);

Can we legitimately get NULL kobj or kobj->dentry here?  If not, that'd
better be BUG_ON()...

> @@ -65,15 +98,28 @@ int sysfs_create_link(struct kobject * k
>  	struct dentry * d;
>  	int error = 0;
>  
> +	if (!name)
> +		return -EINVAL;

Again, can that happen legitimately?

>  	down(&dentry->d_inode->i_sem);
>  	d = sysfs_get_dentry(dentry,name);
>  	if (!IS_ERR(d)) {
>  		error = sysfs_create(d, S_IFLNK|S_IRWXUGO, init_symlink);
> -		if (!error)
> -			/* 
> -			 * associate the link dentry with the target kobject 
> -			 */
> -			d->d_fsdata = kobject_get(target);
> +		if (!error) {
> +			struct sysfs_dirent * sd;
> +			sd = sysfs_add_link(dentry->d_fsdata, name, target);
> +			if (!IS_ERR(sd)) {
> +				/* 
> +			 	* associate the link dentry with the target  
> +			 	* through the corresponding sysfs_dirent.
> +			 	*/
> +				d->d_fsdata = sd;
> +				sd->s_dentry = dentry;
> +			} else {
> +				dput(d);
> +				error = PTR_ERR(sd);
> +			}

	I'd pull that inside sysfs_add_link() (and then further into
sysfs_new_dirent()).

      parent reply	other threads:[~2004-08-03 12:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-29 20:37 [PATCH 0/5] sysfs backing store (Re-splitted) Maneesh Soni
2004-07-29 20:38 ` [PATCH 1/5] Add sysfs_dirent to sysfs dentry Maneesh Soni
2004-07-29 20:39   ` [PATCH 2/5] Use sysfs_dirent tree for ->readdir etc Maneesh Soni
2004-07-29 20:40     ` [PATCH 3/5] Free sysfs_dirent on file removal Maneesh Soni
2004-07-29 20:43       ` [PATCH 4/5] Change sysfs_file_operations Maneesh Soni
2004-07-29 20:44         ` [PATCH 5/5] Stop pinning dentries & inodes for leaves Maneesh Soni
2004-08-03 13:02           ` viro
2004-08-03 12:57         ` [PATCH 4/5] Change sysfs_file_operations viro
2004-08-03 12:52       ` [PATCH 3/5] Free sysfs_dirent on file removal viro
2004-08-03 12:47     ` [PATCH 2/5] Use sysfs_dirent tree for ->readdir etc viro
2004-08-03 12:43   ` viro [this message]

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=20040803124329.GS12308@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maneesh@in.ibm.com \
    /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®