Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3525686pxj; Mon, 24 May 2021 08:39:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyePB+OqMIX6yLJHyrzXl8CDyHOhgXRC+5+OzBQw6ZMymPY1vIFaugf1M8uCkEr+rH7kDnZ X-Received: by 2002:a17:906:5495:: with SMTP id r21mr24254052ejo.471.1621870770721; Mon, 24 May 2021 08:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870770; cv=none; d=google.com; s=arc-20160816; b=c2wKoEPl8z3/C5GKmKOuFvyfUG40pTJu5uONtgXwuoQdlU1ByLS0KBvvuvh47N7/nK 9Gqq/yo7/aC1E1gDud2ZIAgUG4Tr/Z9/6dq8570jDTKkvZsggDK8k8RbMfKsHBjlSJWs 8gRwtUBZBNirkR9tOocUUG3ufv455H1GpiqvbfKmkLw33skcJ76IhQlzlLfIC3fshnbt 8CX8AH78J2UwtfGTB3o0QwKwFJOEkKHz15w8iJVWfQ4Dh2KA8pV8ugnmsUjnevP9Epdq t8RQwHTkVEwh/Y08NPODpkJLIRKmOQqWtdAeo5vfPQEsNfgkZhtHk2Kqb/hC89nUO7/L 6AGw== 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=2cCRHepGAEdgqMiR6zBRbN20pMhuykvjQyZlqtHeRdo=; b=AcK3OufDtYYk18i3mx2xXuZMbnIMjEpI+f2VYkCm9F6DhVEGPAPbPiQYQ/phIOF0H3 iafiwMqHnueuDGLqtxGSr98wMsHS25T3/swN7Qy+hxJVZEsgHOeWJQppRsh3KPIrDFKa c46au6/71OyuqcWfVJbypXhYebcaz/weCvIUvVs/nSZB3FE6QYCwaLIyfdO+lrGpI2mC lmIcpK6Zsl6abCIy7qS5mXtYZ3F/EOgkzujDp/T/HNSvDI7vKXCP36IbHgGhSNmcA78h NvHuwHjbtyWAC9Gtkt3nRPOHeLgkCZNoC9Ir7SwVrp8etyyDnrUkRyDRoAW5eg2xeU7s JMGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mj85q3AH; 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 r23si13115556edq.47.2021.05.24.08.39.07; Mon, 24 May 2021 08:39:30 -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=mj85q3AH; 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 S234301AbhEXPja (ORCPT + 99 others); Mon, 24 May 2021 11:39:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:50506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233885AbhEXPgX (ORCPT ); Mon, 24 May 2021 11:36:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C688261413; Mon, 24 May 2021 15:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870364; bh=15oc/WjcNzfjmfguWvMxeJ7cZRbaFID4/OV0DFsxLz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mj85q3AHQEQuW+9g4J6+FZeby4UhTeYWQ66s24Y4sTLfTZxpaZIzujuf1W1WTZ6tz xxwJcJjCp47Ay5VPTba2mbeXTCKg6FyLr+feV6Z3Bzu36hk0AoXixqoXjQMdPyc20P G+aSNAjj3vlINVzoxsrf23Ix3DuLOhNT475xbmg4= 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.9 23/36] cdrom: gdrom: initialize global variable at init time Date: Mon, 24 May 2021 17:25:08 +0200 Message-Id: <20210524152324.912387378@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.158146731@linuxfoundation.org> References: <20210524152324.158146731@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 @@ -773,6 +773,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"); @@ -867,7 +874,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;