Skip to content

Commit

Permalink
[SCSI] Fix SCSI tape oops at module removal
Browse files Browse the repository at this point in the history
Removing the SCSI tape module results in an oops in class_device_destroy if
any devices are present. The patch at the end of this message fixes the bug
by moving class_destroy() later in exit_st() so that the class still exists
when devices are removed. (The bug is old but class_simple_device_remove() did
nothing when the class did not exist.)

The patch also fixes a "class leak" in init_st() error path.

I would like to get this into 2.6.13 but it may be too late?

Signed-off-by: Kai Makisara <kai.makisara@kolumbus.fi>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
  • Loading branch information
Kai Makisara authored and James Bottomley committed Aug 2, 2005
1 parent c1a1546 commit c2c96f4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/scsi/st.c
Original file line number Diff line number Diff line change
Expand Up @@ -4149,26 +4149,22 @@ static int __init init_st(void)
do_create_driverfs_files();
return 0;
}
if (st_sysfs_class)
class_destroy(st_sysfs_class);
unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),

ST_MAX_TAPE_ENTRIES);
}
class_destroy(st_sysfs_class);

printk(KERN_ERR "Unable to get major %d for SCSI tapes\n", SCSI_TAPE_MAJOR);
return 1;
}

static void __exit exit_st(void)
{
if (st_sysfs_class)
class_destroy(st_sysfs_class);
st_sysfs_class = NULL;
do_remove_driverfs_files();
scsi_unregister_driver(&st_template.gendrv);
unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
ST_MAX_TAPE_ENTRIES);
class_destroy(st_sysfs_class);
kfree(scsi_tapes);
printk(KERN_INFO "st: Unloaded.\n");
}
Expand Down

0 comments on commit c2c96f4

Please sign in to comment.