Commit acfeb23b authored by Matthew R. Ochs's avatar Matthew R. Ochs Committed by Martin K. Petersen

scsi: cxlflash: Avoid double free of character device

The device_unregister() service used when cleaning up the character
device is already responsible for the internal state associated with the
device upon successful creation. As the cxlflash driver does not obtain
a second reference to the character device, the explicit call to
put_device() is not required and can lead to an inconsistent sysfs among
other issues as the reference is no longer valid after the first
put_device() is performed.

Remove the unnecessary put_device() to remedy this issue.

Fixes: a834a36b ("scsi: cxlflash: Create character device to provide host management interface")
Signed-off-by: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent f9279c96
...@@ -923,7 +923,6 @@ static void cxlflash_put_minor(int minor) ...@@ -923,7 +923,6 @@ static void cxlflash_put_minor(int minor)
*/ */
static void cxlflash_release_chrdev(struct cxlflash_cfg *cfg) static void cxlflash_release_chrdev(struct cxlflash_cfg *cfg)
{ {
put_device(cfg->chardev);
device_unregister(cfg->chardev); device_unregister(cfg->chardev);
cfg->chardev = NULL; cfg->chardev = NULL;
cdev_del(&cfg->cdev); cdev_del(&cfg->cdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment