Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3542357pxj; Mon, 24 May 2021 09:01:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEXgYDPLEI3l9+oh5L3y0d0cPzypqIFKKwo3sAJ6OGxY1achIzz+Pzd/CQCl6LHxqzq6F0 X-Received: by 2002:a6b:ec03:: with SMTP id c3mr16155364ioh.103.1621872106463; Mon, 24 May 2021 09:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872106; cv=none; d=google.com; s=arc-20160816; b=vhNDHaEB0TrD1udyTznQBdASa0Bf/zbG6gnANQs6L2Vx+t6OlhHZtyPwGExtmF5qRT qIpAIBOLM2MWR059VTcLfgbgJnQ9qG/A5CsAwvGsLmXw0z6Xvtb3+yzuiwZTRNdjXlDi Lg1y8MBzWoyiUJvF6H95FWeuWj4WflqCHpILDKcp1iesH+xhNPexeGQf88GbARdi7zBC 4Dhdt126pwyKaZzrxgIJ0m2I3sdoRljbSK97lV0Ga9FFYoGqvzUa3siGeEGXJ7sdoxwj 9AES8AGPSVLGSjXWPD/Hn57Ign1R1eSzm+5dVc27P1lUQGE7zDRMMSQ6MqpaDF3QemLy WeBw== 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=f+Vazt4yFHw5iuW6Zn+bg2Ah3INXftmcYlV02bosIYREYRs3lJt43WfOoffta2Qac8 7Emxn8sw3AJOYawFRfCUP4FglLHiYuXAkVlN1inV4hfEgs7HceJYJ6bcTB+1qfcKlCgo DBu4YZg1YiDz9ClyESRAWZyjZX0UiyN9rkM8aVLbLqk2TfwUL02ivYfGfkORYIuUcI2H kXKRuAg753qhSLAQs12jSdGyL/0akJ1FGJUXlK3xOrvR5noJnl6Lt808Bdynh9qw3vgn AjTRiNzjM+EF1DS0/7DfKLbda931tyIUTia5HOXFamFhCCBbW2gxvU/R/Hm2gseu4+Oq tz1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1CEjtOkA; 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 d8si13985466ilo.3.2021.05.24.09.01.31; Mon, 24 May 2021 09:01:46 -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=1CEjtOkA; 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 S235847AbhEXQBO (ORCPT + 99 others); Mon, 24 May 2021 12:01:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:39394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235486AbhEXPzJ (ORCPT ); Mon, 24 May 2021 11:55:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B1736109F; Mon, 24 May 2021 15:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870894; bh=fFISBQGlswKV4ngHO+piUv/DQV2UOjaGUS2vzv1mwvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1CEjtOkA40wWvmpBPA/8RcbxgWUv9QGSvcVXr3ai5z4/nQP6mm+/nlHcIx2sbkce5 T2afi73x0ehPH7Nt4FvDPN49cmfXAn5FwXPiezEtTSgRW65cFazMTM4F1eqvJTde4u jp+ESFy1ebqwgrt/zkYwBduT4jLt6NoJOQUhXlGE= 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.10 082/104] cdrom: gdrom: initialize global variable at init time Date: Mon, 24 May 2021 17:26:17 +0200 Message-Id: <20210524152335.572311639@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@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;