Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3550395pxj; Mon, 24 May 2021 09:10:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGKPGRcqzMxYYqELqIIizWfUwQzv3DUdFyRWVPPEncnEPaqxYwgBXKHiCtiVUA0MXQ3oYM X-Received: by 2002:a02:a409:: with SMTP id c9mr21896464jal.43.1621872617194; Mon, 24 May 2021 09:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872617; cv=none; d=google.com; s=arc-20160816; b=Vckgs7shjrRF7z2wXtyRmsnOjxqGQ/SotnQUoRl0iJAwg1DveXabxQTgZhEhdLdQO7 v7YhLs/NYv1qaNU7dAYRRPyvndoVc3iVwlzyQOmhRCXTzy0jyMhwb8RrdN9WIp7sBmxP flJVOYLFVuF+ALK6XMVTj/4lAe71aoTj3uLLFcRaxPr8IRTII6w1iXMd/zyOL8y694y8 +BE9BOi4ttwgP7XMS+gqfb6okFMXRP0gT5W3N5bzl2/7YWF6eVrzfY+NolljH/oX+Otq OZ2YYUho18mktCVsdZjm18yykxwjb4gY2tYsfZmydlGix8YXNj6ZYto/72OTWmf1Httw 4fHA== 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=qEZg57J4VZ4YlQukXvaaRDfMlZVM+Er+UHgBHs0fhUM=; b=F6kEh7LXJ3+XcpmY+Js6WJ/5bd60s9wZfi1fwqsujhb4I2jRQkG/24DYKqotDGTgor /040mpnYqQEd7TdAkDn8QlB93rwArBeeoeyi4OJdJN+cFHS3V10Z3Yq9kPO8iYX8/xoj KkP08AUjwuHE8Z/1+LUM5/zN3e+jR8G6DGJQ4m1ZALDiLCpu5hV4sgMH1AsZRFCFkqOa 4nb+5Q/ECQ/qmRdhwZloqnbs//v0Wg1X7WefpCRRVpqk0xCpwkFDbA8yL2DhnSVA8Ow3 q4KhwXYYXCTbtv3Ur/JMwUUH4vO23YAFCWjTR6/yZv0rCt8mJRv6R+6gVDfPGGRFJTXj O6HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tKr2sbgq; 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 e22si14779822iog.50.2021.05.24.09.10.03; Mon, 24 May 2021 09:10:17 -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=tKr2sbgq; 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 S238751AbhEXQKU (ORCPT + 99 others); Mon, 24 May 2021 12:10:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:43814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234061AbhEXQCW (ORCPT ); Mon, 24 May 2021 12:02:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9485B619A3; Mon, 24 May 2021 15:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871231; bh=fFISBQGlswKV4ngHO+piUv/DQV2UOjaGUS2vzv1mwvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tKr2sbgqJfZuchW6x8KARgmxSPOGBI0WN+n3Tye34pXGTNRz60yXZ+iMqsnxWVqlI AsmJN33bPS4FCZbSWZraX8RXRoNrJ5G/J5fJeq6z9cGAjjjoDb0WvXkWtQXQUkuR0s UaPz4ONOHJWTwMen9OgCwabTvi+U8AlLmdNl+b9E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Rosin , Jens Axboe Subject: [PATCH 5.12 105/127] cdrom: gdrom: initialize global variable at init time Date: Mon, 24 May 2021 17:27:02 +0200 Message-Id: <20210524152338.402040425@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@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 @@ -743,6 +743,13 @@ static const struct blk_mq_ops gdrom_mq_ 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_warn("ATA Probe for GDROM failed\n"); @@ -848,7 +855,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;