Skip to content

Commit 903bf81

Browse files
committed
cdrom: gdrom: initialize global variable at init time
commit 9183f01b5e6e32eb3f17b5f3f8d5ad5ac9786c49 upstream. As Peter points out, if we were to disconnect and then reconnect this driver from a device, the "global" state of the device would contain odd values and could cause problems. Fix this up by just initializing the whole thing to 0 at probe() time. Ideally this would be a per-device variable, but given the age and the total lack of users of it, that would require a lot of s/./->/g changes for really no good reason. Reported-by: Peter Rosin <[email protected]> Cc: Jens Axboe <[email protected]> Reviewed-by: Peter Rosin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 151881f commit 903bf81

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/cdrom/gdrom.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,13 @@ static int probe_gdrom_setupqueue(void)
773773
static int probe_gdrom(struct platform_device *devptr)
774774
{
775775
int err;
776+
777+
/*
778+
* Ensure our "one" device is initialized properly in case of previous
779+
* usages of it
780+
*/
781+
memset(&gd, 0, sizeof(gd));
782+
776783
/* Start the device */
777784
if (gdrom_execute_diagnostic() != 1) {
778785
pr_warning("ATA Probe for GDROM failed\n");
@@ -867,7 +874,7 @@ static struct platform_driver gdrom_driver = {
867874
static int __init init_gdrom(void)
868875
{
869876
int rc;
870-
gd.toc = NULL;
877+
871878
rc = platform_driver_register(&gdrom_driver);
872879
if (rc)
873880
return rc;

0 commit comments

Comments
 (0)