Re: [Patch] Fix oops on rmmod usb-storage

From: Matthew Wilcox
Date: Wed Sep 29 2004 - 10:37:04 EST


On Wed, Sep 29, 2004 at 11:15:13AM -0400, James Bottomley wrote:
> struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int gfp_mask)
> {
> - struct scsi_cmnd *cmd = __scsi_get_command(dev->host, gfp_mask);
> + struct scsi_cmnd *cmd;
> +
> + /* Bail if we can't get a reference to the device */
> + if (!get_device(&dev->sdev_gendev))
> + return NULL;

How can this happen? You're taking the address of dev->sdev_gendev, so it
can't be NULL:

struct device * get_device(struct device * dev)
{
return dev ? to_dev(kobject_get(&dev->kobj)) : NULL;
}

(kobject_get returns its argument).

--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/