Skip to content

Commit 6555781

Browse files
nomismartinkpetersen
authored andcommitted
scsi: sr: Fix sr_probe() missing deallocate of device minor
If the cdrom fails to be registered then the device minor should be deallocated. Link: https://lore.kernel.org/r/072dac4b-8402-4de8-36bd-47e7588969cd@0882a8b5-c6c3-11e9-b005-00805fc181fe Signed-off-by: Simon Arlott <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent a247e07 commit 6555781

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/scsi/sr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static int sr_probe(struct device *dev)
793793
cd->cdi.disk = disk;
794794

795795
if (register_cdrom(&cd->cdi))
796-
goto fail_put;
796+
goto fail_minor;
797797

798798
/*
799799
* Initialize block layer runtime PM stuffs before the
@@ -811,6 +811,10 @@ static int sr_probe(struct device *dev)
811811

812812
return 0;
813813

814+
fail_minor:
815+
spin_lock(&sr_index_lock);
816+
clear_bit(minor, sr_index_bits);
817+
spin_unlock(&sr_index_lock);
814818
fail_put:
815819
put_disk(disk);
816820
mutex_destroy(&cd->lock);

0 commit comments

Comments
 (0)