Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3538796pxj; Mon, 24 May 2021 08:57:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyo19ZDKpBJJNJs4fVok13ipz78vX72wHHuTfXHthMlR3LQQea2sifAlOjIgjB/ptOBbza8 X-Received: by 2002:a05:6602:2013:: with SMTP id y19mr16722429iod.71.1621871860439; Mon, 24 May 2021 08:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871860; cv=none; d=google.com; s=arc-20160816; b=oxpYw/RbZJ3mgebtLsLOBg73HQygxYjpHq+kSrhHjxXreii/GdW1PlUmRLe0oHQGp8 x3U5SfWp8ukFfzFvEn64t92bJiFdjbsbBKQWhtluqo0m/LkaM7fXLbX9nPo5fJajoZmw l91VaKm2d2vXCzYl4QeCy2GHiw/N1T/whJzR+2qKUxqxZoZzYRW5l674+mUTuj/GxZmd CDJPSnDhDjikFM+r3FfSov/9qmT7ck0WyP/i9kaLklXsgNiXHGcyU/1BXjQkzzZUumBc YD8EEoYc5nd94su7wr1pKj5JXaQBVx5JIuWqjYLwwscvsSVXBrtlF3D98n54MrUvzbeW BuzQ== 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=Pbhjcix3fDVlDqMeAUyF/0T3ZMRFUNgOxpm7jdOv3R0=; b=g8lzhrmHwYunUpW/DfiGCuTkdfRtGsDREsH6tCagPRUn/v+HLGdRnNxgei6jJ3X77a 0JlGk8x6+7avtwEtGFf9Y/rM5uCWSxYjFkyDvMQSwl8pc86z2w88FHQ4RguspZamJ222 /R/+HmeO9A4Pbfhqx993qGaVly6pJGIHO4qjHOTNvyt4f4sXt0nihDOpW81msGTaItrG uEanEupVbP6v0OCvb9BoI4JLUtV4ax7Nx8BeYIDim9ULusUElHTWo6ljtIeS+2R17oBy yMD7wl1wV5Z1hWlk7q1cggdl3ETIuJ9zji8mBGOr1E1mTrqEVEiVt4IMeycx3RUksC50 d2iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wh+zcksA; 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 z20si14010701ioe.51.2021.05.24.08.57.27; Mon, 24 May 2021 08:57:40 -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=wh+zcksA; 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 S234131AbhEXP4u (ORCPT + 99 others); Mon, 24 May 2021 11:56:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:35156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234711AbhEXPt3 (ORCPT ); Mon, 24 May 2021 11:49:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C17761580; Mon, 24 May 2021 15:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870675; bh=wEin2Bf0hytRAmNp5kWe6+IfC5psva2MM1khbyHowAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wh+zcksAro+rkjMVhfeKsHVOSe0Bhnf6O4azMgXP7Fs3vnjBM1MZ46s2EEpnLosGo wPeTLmbbcKVBfUDjQ019zGzgLlM8/jG8jXXpHes12TJNfoUe04F4EifPemGDysh8tH MkLKz2KYq9j+4Pq1u9+A/zUn1rk8vsF8/7gbv5yQ= 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.4 53/71] cdrom: gdrom: initialize global variable at init time Date: Mon, 24 May 2021 17:25:59 +0200 Message-Id: <20210524152328.182945139@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152326.447759938@linuxfoundation.org> References: <20210524152326.447759938@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 @@ -740,6 +740,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_warning("ATA Probe for GDROM failed\n"); @@ -845,7 +852,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;