All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Koeller <thomas.koeller@baslerweb.com>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Device class reference counting
Date: Fri, 6 Aug 2004 11:37:46 +0200	[thread overview]
Message-ID: <200408061137.47099.thomas.koeller@baslerweb.com> (raw)
In-Reply-To: <20040805224656.GA22545@kroah.com>

On Friday 06 August 2004 00:46, Greg KH wrote:
> On Fri, Jul 30, 2004 at 06:03:00PM +0200, Thomas Koeller wrote:
> > Hi,
> >
> > I found a little issue with reference counting for
> > device classes in 2.6.8-rc2. Patch attached.
> >
> > --- linux-mips/drivers/base/class.c	2004-07-14 16:21:33.000000000 +0200
> > +++ linux-mips-work/drivers/base/class.c	2004-07-30 17:51:09.477331128
> > +0200 @@ -353,8 +353,8 @@
> >  	struct class_interface * class_intf;
> >  	int error;
> >
> > -	class_dev = class_device_get(class_dev);
> > -	if (!class_dev || !strlen(class_dev->class_id))
> > +	if (!strlen(class_dev->class_id)
> > +		|| !(class_dev = class_device_get(class_dev)))
> >  		return -EINVAL;
>
> I don't understand what you are trying to fix here.  In fact, if
> class_dev is NULL, you will now oops.
>
> Hm, I guess if class_dev->class_id is null, we will exit with an extra
> reference grabbed on the class_dev.  Is that what you are trying to fix
> here?
>
> If so, please rework the patch.
>
> thanks,
>
> greg k-h

You guessed it - pretty obvious, isn't it? Well, I assumed the case
where class_dev is NULL didn't matter, as this could only happen if
there is a bug in some other place - seems I was wrong. So how's
about this patch:


--- linux-mips/drivers/base/class.c     2004-07-14 16:21:33.000000000 +0200
+++ linux-mips-work/drivers/base/class.c        2004-08-06 11:06:10.983688216 +0200
@@ -349,14 +349,19 @@

 int class_device_add(struct class_device *class_dev)
 {
-       struct class * parent;
+       struct class * parent = NULL;
        struct class_interface * class_intf;
        int error;

        class_dev = class_device_get(class_dev);
-       if (!class_dev || !strlen(class_dev->class_id))
+       if (!class_dev)
                return -EINVAL;

+       if (!strlen(class_dev->class_id)) {
+               error = -EINVAL;
+               goto register_done;
+       }
+
        parent = class_get(class_dev->class);

        pr_debug("CLASS: registering class device: ID = '%s'\n",



-- 
--------------------------------------------------

Thomas Koeller, Software Development
Basler Vision Technologies

thomas dot koeller at baslerweb dot com
http://www.baslerweb.com

==============================

  reply	other threads:[~2004-08-06  9:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-30 16:03 [PATCH] Device class reference counting Thomas Koeller
2004-08-05 22:46 ` Greg KH
2004-08-06  9:37   ` Thomas Koeller [this message]
2004-08-06  9:43     ` Thomas Koeller
2004-08-06 19:47       ` Greg KH
2004-08-10 12:09         ` Thomas Koeller
2004-08-10 23:28           ` Greg KH

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=200408061137.47099.thomas.koeller@baslerweb.com \
    --to=thomas.koeller@baslerweb.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.