Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1384484pxy; Thu, 6 May 2021 07:01:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3xuHCUN7MK9xKKb95LWaDp3Kt0VcSLzVO5F0qJpmaCdB5LFy4IE6c+VOAshwjZyA32nH5 X-Received: by 2002:aa7:8103:0:b029:247:74a8:e54d with SMTP id b3-20020aa781030000b029024774a8e54dmr4957550pfi.60.1620309716261; Thu, 06 May 2021 07:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620309716; cv=none; d=google.com; s=arc-20160816; b=lMvDTyImPKU6nIsJGiUoqbpZ+pRDrWbftLdEKPNmBOidqGMV4Izxz0jO2u7dMEPbS4 vHLtqXYJ7BjCc5Rqh7mBwfNzS+AsbFsKrCCTvbCvdXyRae/2YWhAEILacnMs+8JxWz6t +rF94l/5Fv4BSZHgL5iPJlTMJQgYiCkMbj3kFyWquiSSXTWRnX6IbxhTf6I53j0WKHW/ tnKigGAUr05SjcNKt4RtQgm8bp6veCDPOk1tQkha1Acy77xkwN8MBDasWZjWiHQ5aFYk lPpl64j2XNlxNCJeMDzT5RVi3hz/mGPyBl47RKdIwlPI1SZylQy3t+hjzI120BEM4BZX fgrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ucYRulNuyPTNgKVSJSWMswDlaHBqAQvWWzHktKNXQWY=; b=uC5WIw3ZVzvSkcJnxdklgRroqPmttLs6cmTVrNTBCyyBIMYleBF9yr3OlzI3GnA2/0 dJOJCnwEE2v/fqdbS9AEdaDMK/a+o0UY1Ok3Ccru7HoUf5d9CG5TFqcGfDb+EYQuoSAh /wzGiUN0tqDG/lKlmUmO0nxlNMXikjpoy+Xsmym/e630oitkbq6/delJrouELaoV/g+y Eh9dxmzZmG3yqXsNOGgf4YWsCo2qNdWIdmTGCuL9YNvvpwY84HONucxfYr3Xf0B5fCp3 1hZdvuqe+6bsokg99TY5Ttcn4BTz8X+YzmXaoRo4TF5/XQ3z6RwWp1BImTU+l2gZqcKj wF/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FH03nBlu; 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 17si3371874pfw.63.2021.05.06.07.01.43; Thu, 06 May 2021 07:01:56 -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=FH03nBlu; 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 S234557AbhEFOBs (ORCPT + 99 others); Thu, 6 May 2021 10:01:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:37248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbhEFOBr (ORCPT ); Thu, 6 May 2021 10:01:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3832B610FC; Thu, 6 May 2021 14:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620309649; bh=iq4hOzh6K2US8KJMLeXxFDLRjf5bYv2Fq5efxCMz7yI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FH03nBluc5WCGvlxaUmU7xgUh3uEJaz377/KWmzp1HrHitOoiCR8Hwhj9/MGWMrla bpOJX3RXB/sn9k62a2BAjMDJOUUtocUEhIE/EXRUjs0S8+XpmTyfq8K/tdpFzs3oLZ 4TVzrvPE1g7mvfh5+ZTUAhcZ9jFyVC5vWHF+XtZo= Date: Thu, 6 May 2021 16:00:47 +0200 From: Greg Kroah-Hartman To: Peter Rosin Cc: linux-kernel@vger.kernel.org, Atul Gopinathan , Jens Axboe , stable Subject: [PATCH] cdrom: gdrom: initialize global variable at init time Message-ID: References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> <20210503115736.2104747-28-gregkh@linuxfoundation.org> <223d5bda-bf02-a4a8-ab1d-de25e32b8d47@axentia.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman 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 Signed-off-by: Greg Kroah-Hartman --- Note, this goes on top of my previous "gdrom" patch submitted here: https://lore.kernel.org/lkml/20210503115736.2104747-28-gregkh@linuxfoundation.org/ And I'll just take it in the same series. drivers/cdrom/gdrom.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index 6c4f6139f853..c6d8c0f59722 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -744,6 +744,13 @@ static const struct blk_mq_ops gdrom_mq_ops = { 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"); @@ -847,7 +854,7 @@ static struct platform_driver gdrom_driver = { static int __init init_gdrom(void) { int rc; - gd.toc = NULL; + rc = platform_driver_register(&gdrom_driver); if (rc) return rc; -- 2.31.1