Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3527980pxj; Mon, 24 May 2021 08:42:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1ZHZvS+HuhZs1HVZlvp9mYKH2OAev96zzMCZqVVsdKr9embaiK/3iS3z8TIZ2582E7Vsx X-Received: by 2002:a17:906:3b10:: with SMTP id g16mr24531166ejf.232.1621870958558; Mon, 24 May 2021 08:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870958; cv=none; d=google.com; s=arc-20160816; b=ijZmtnfdcCtXY6/ZbO25qa9+HW9WuH3egIGYvoMUbrtajl5G5KfMIb8tCLI0QiVrAW NqXAHXPQI3Xy6xIr1h943H9wA17Rw48X9jwSsuVyJBs2OrUOSYzs+LSjgt/l414hufcX vAE9+sIDdoKPGtO0zmGuZhL6fgwwwNImNbzSYXKMF89tEYNVRd8bSKI415T23+VsfugB HjlxpSH8oGllhfeMw9dQy9v3B0n9zrfW5uEc5utq1uXw89iq/UrnO0ymmxGqh6QTwS74 NsspLwvH5FF+vNHJTbn39DAk0U5SayxBtezYJKwwjmiImkD1Wwjelv+NUvJn8D4X7Suw gxOA== 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=aiFskL/N0MX5OuWBR8jEE8l68TSEPVADaqXwPnOVKsY=; b=wpRmi1banwvUKLz4SwjiRwcNE5ip+A59pBzFjKdBOmKVSIMTRAlaCi+K1g+v/vGVD2 tmBsj9Cr9SszirOus1nlqtvxx8I+F8eT8DfnXFilzKhCdSMtgS0EnSbcCTxaJ+oDVLQa yYDv/w8KKDyOfPF3AD6XFEfJvhpkn439g6ZlimZIUCQ5UQZkib8R0zfFNubbyTSP/u5e AHA2SfMYV9Tf2vgaPrHypKPBi8LZdCo8EzlvpywduYDpKyMM7cQc3RkxOUk70NU9SPyC Am0hnRu/3N1+L25XPT5cEuXyXcV1y5YdMr/4m1dimIzBmgD7wJoEW79kcNpQTokCT6/3 llsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="moJ/Il4a"; 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 dy15si12050658edb.502.2021.05.24.08.42.15; Mon, 24 May 2021 08:42:38 -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="moJ/Il4a"; 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 S233634AbhEXPmz (ORCPT + 99 others); Mon, 24 May 2021 11:42:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:56500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234075AbhEXPib (ORCPT ); Mon, 24 May 2021 11:38:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EB7D9613F9; Mon, 24 May 2021 15:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870416; bh=eEKu4rUipG99VsW2aieIlLdvMnpIWxopf7nGFOwMgBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=moJ/Il4a1/irXbpz5+5sQ6Q8B0m+as1E1UcX0ACnPVplwR8ID0MmEi4unMV5TzVG/ QeMcxBfdq/m8gasuknDh4SKoEMYknIl08kCB9KqnLipguAfiIv5PLJGkI2qnSnG52f w8RvGdX0iEw4wJKyx7ow6fzLspCyNg8HK+iy81Mw= 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.14 24/37] cdrom: gdrom: initialize global variable at init time Date: Mon, 24 May 2021 17:25:28 +0200 Message-Id: <20210524152324.994931391@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.199089755@linuxfoundation.org> References: <20210524152324.199089755@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 @@ -775,6 +775,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"); @@ -874,7 +881,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;