Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3531212pxj; Mon, 24 May 2021 08:47:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm6yXnU+nMOZ0cBQN5hE2HvMS9CeJtjkrCJ4HCfRUUfXKqSGBlTDRiB8dfLtBfJ8HA/KSO X-Received: by 2002:a02:5409:: with SMTP id t9mr25689167jaa.50.1621871242647; Mon, 24 May 2021 08:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871242; cv=none; d=google.com; s=arc-20160816; b=zVL9Zi/zcg9wrhirtRV6HYA1txuCReTOCBLlfuIxW4v6xV2kK0Wr3Hsye23FkxP+6I fFLQUlPI/KGzyUwCKv9qEPPaOZ7bMX33NDpbG6Ncs4Aj3U05YlrAy7ELdRPvCXn1TZV5 99g+ngvxi/JiV68EbDmalOu0xHaQ3j3t8Z3hMfVow565IvBiQFEO2puK9DDm16gSoYSd AfmrLK72mYXbPS05V7ZIvgupMi05hsw3ltDr2aBBhk2z3mLmADxna70pC5tsWb5WPi8m SyvAaz8ItuoShUCNtsVId02sTol2nHZ0J4PyYYFBRuo9IM1UFF5JkYcm356W4ejjtif3 bAUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aiFskL/N0MX5OuWBR8jEE8l68TSEPVADaqXwPnOVKsY=; b=flGd9N9FbcM3FW09fnVeMGf/GABStmBxpD4NwL3uxYzXYY9vuh+QE61mKj1cu4k4aD 8hW2qGdpQNBnte6qRFi7v1v9uBxZXrN6xD1qDmeRbfeXadLU24jOHh0aIzVGpTam0YjT hVdxmHQmFQXpZInu0897YE8WZLrtIRojowgrkk2I8h4+pUWRqu6JaShv80Iu1OK9Y8Oa 60YAW2J2Job94UaSjtHdXnVhKaP3SWYLDswTEMIpqd176FYqnsDZtl1Kc+kKw0ZSqPPO CVmTtqTt1KzBe9BL06vKKXEEmNU59aiOAmiKL4r/r43rVQIC53t4vwHxN2+zvlnsp7+o 6LwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=szcJEWoQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si14253883ila.98.2021.05.24.08.47.09; Mon, 24 May 2021 08:47:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=szcJEWoQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233945AbhEXPsB (ORCPT + 99 others); Mon, 24 May 2021 11:48:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:57092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234135AbhEXPnI (ORCPT ); Mon, 24 May 2021 11:43:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 99FA1613B6; Mon, 24 May 2021 15:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870523; bh=eEKu4rUipG99VsW2aieIlLdvMnpIWxopf7nGFOwMgBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=szcJEWoQke9tqWiBzIqZuNOIImPwpnfLVBKUpoZKLFMy0C9yU1Ze92fXIlTd+4xmp bxNXw+tGTuZH4ESdayM9Qcf9XIqxtvXLFxglPlRBttVf7LYGdvwlHOyl5gi2YHCqKe YsRUjMhIZz5xEwYK/4W1dyF6XZ5oAJW5pyf06zSM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Rosin , Jens Axboe Subject: [PATCH 4.19 34/49] cdrom: gdrom: initialize global variable at init time Date: Mon, 24 May 2021 17:25:45 +0200 Message-Id: <20210524152325.481203363@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.382084875@linuxfoundation.org> References: <20210524152324.382084875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman 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 Cc: Jens Axboe Reviewed-by: Peter Rosin Link: https://lore.kernel.org/r/YJP2j6AU82MqEY2M@kroah.com Signed-off-by: Greg Kroah-Hartman --- drivers/cdrom/gdrom.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -775,6 +775,13 @@ static int probe_gdrom_setupqueue(void) static int probe_gdrom(struct platform_device *devptr) { int err; + + /* + * Ensure our "one" device is initialized properly in case of previous + * usages of it + */ + memset(&gd, 0, sizeof(gd)); + /* Start the device */ if (gdrom_execute_diagnostic() != 1) { pr_warning("ATA Probe for GDROM failed\n"); @@ -874,7 +881,7 @@ static struct platform_driver gdrom_driv static int __init init_gdrom(void) { int rc; - gd.toc = NULL; + rc = platform_driver_register(&gdrom_driver); if (rc) return rc;