All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Michael Reed <mdr@sgi.com>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	dougg@torque.net, Jeremy Higdon <jeremy@sgi.com>
Subject: Re: panic in sg_add when class_device_create() fails
Date: Mon, 14 Jan 2008 16:28:51 -0600	[thread overview]
Message-ID: <1200349731.3159.76.camel@localhost.localdomain> (raw)
In-Reply-To: <478BDE18.2010600@sgi.com>


On Mon, 2008-01-14 at 14:11 -0800, Michael Reed wrote:
> We're seeing an occasional panic in sg_add() when class_device_create()
> fails.  It's obvious in the code that it uses the pointer to sg_class_member
> even though it's invalid.  We do see the "class_device_create failed" message.
> 
>         class_set_devdata(cl_dev, sdp);
>         error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1);
>         if (error)
>                 goto cdev_add_err;
> 
>         if (sg_sysfs_valid) {
>                 struct class_device * sg_class_member;
> 
>                 sg_class_member = class_device_create(sg_sysfs_class, NULL,
>                                 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
>                                 cl_dev->dev, "%s",
>                                 disk->disk_name);
>                 if (IS_ERR(sg_class_member))
>                         printk(KERN_WARNING "sg_add: "
>                                 "class_device_create failed\n");
>                 class_set_devdata(sg_class_member, sdp);
>                                   ^^^^^^^^^^^^^^^^
>                 error = sysfs_create_link(&scsidp->sdev_gendev.kobj,
>                                           &sg_class_member->kobj, "generic");
>                 if (error)
>                         printk(KERN_ERR "sg_add: unable to make symlink "
>                                         "'generic' back to sg%d\n", sdp->index);
>         } else
>                 printk(KERN_WARNING "sg_add: sg_sys Invalid\n");
> 
> I'm uncertain of the correct fix.  Perhaps it involves a call to cdev_unmap()? 
> I don't have a good way to test a fix as this problem is not easily reproduced.

I think just

error = ERR_PTR(sg_class_member);
goto cdev_add_err;

Will do it, won't it?

James



  reply	other threads:[~2008-01-14 22:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-14 22:11 panic in sg_add when class_device_create() fails Michael Reed
2008-01-14 22:28 ` James Bottomley [this message]
2008-01-15  4:36 ` FUJITA Tomonori

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=1200349731.3159.76.camel@localhost.localdomain \
    --to=james.bottomley@hansenpartnership.com \
    --cc=dougg@torque.net \
    --cc=jeremy@sgi.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mdr@sgi.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 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.