Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6021902ybc; Wed, 27 Nov 2019 13:33:18 -0800 (PST) X-Google-Smtp-Source: APXvYqw+FzZd9BLBeRUqDlRhpBXD6iLR3ZX5joJnKGbEFf57HwzWCg50noI5V/Nup0xGE/Ko4c1M X-Received: by 2002:a17:906:9153:: with SMTP id y19mr3684359ejw.274.1574890398783; Wed, 27 Nov 2019 13:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890398; cv=none; d=google.com; s=arc-20160816; b=mbCqTKpehFYBDKiEEzzSeIQ5GUScpSqRy3/i11AyZ5TkU2MIngjNW1PoICIjvJxAd9 sYYNtVswwCIFsRzaG+MkDlrnGk+LR+UGEQQIRBBox0tiZNM5RzVVJWYYl/bypsx8avqR DdTv5jLtKpo1I5yWsTsFUkYX6l8HnOanndn6PFilz8eVM74heHkBu/nHUbjGqkaldkOW /sKBFBHs7huXasijXic9Y92VgoD8tyb6oXGERMpdZNJ9q6Z3T8cotx0uKODU1mE4kKjk 53i1Kx5SfJmnqU81PklhH+qQtYIYBPdDxYtzBySqLDXJ15gfg4cjsGk83unkr6ac6RaR ukCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nU+82EEsukFDBbDHblg8iyNm6dJoxXWwFw6kjrLOTcc=; b=ENMqhr2iME5W9gygRD0spnV2DflLfyww2SiEyK9kNsMq+OguqhfzY8vGAM/Lq1HGif Wi//27DTnSdzGDHcT8gqWwb1JEK9yGRUUncZGhndSkeXcZjQur2NJ6Rin/uOmQNlWKxi UjYKc+MAqwbb6kAYMo1mC73cM5N0aikfoQTlHaIyfyrRi3oxsIMc3jFbGrffGcx3SG3e euJNynHWzMnrTP/btSFyrfLuhzRhl1biGNn4vHPCg7/Q3gaio7CPkk9STeuwcCBONVBz +gmXEDZk0z9mNzbNpYhDi7G+fg0wSehN79ipGQ18DByedpylQR9iBf1mJdfptGrzmCw5 wvwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ewbduvcV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id by4si11514644edb.87.2019.11.27.13.32.55; Wed, 27 Nov 2019 13:33:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ewbduvcV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730789AbfK0U4r (ORCPT + 99 others); Wed, 27 Nov 2019 15:56:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:47570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731090AbfK0U4p (ORCPT ); Wed, 27 Nov 2019 15:56:45 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8535920862; Wed, 27 Nov 2019 20:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888204; bh=fIClEW6Xb6bv2w8wKJIOdu1DZKfm+EPitpf1xMFHoVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ewbduvcVtCt0yK09poBbhw9jOkAzWM6zpVZ/TEJidIqX/h1f83qn8NAMpQ1F+GacY iXqdKvOoAJKDgftOs3ESrVpHjuW52t+Qzb7FWH7ab5QEZrfzmSTpMVF1kYV16lL/18 0HTfBrMPxNCQWWsHA0KhgmF/NfM9OlPjBK0/Rj0U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ondrej Zary , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 043/306] cdrom: dont attempt to fiddle with cdo->capability Date: Wed, 27 Nov 2019 21:28:13 +0100 Message-Id: <20191127203117.979310204@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jens Axboe [ Upstream commit 8f94004e2a51a3ea195cf3447eb5d5906f36d8b3 ] We can't modify cdo->capability as it is defined as a const. Change the modification hack to just WARN_ON_ONCE() if we hit any of the invalid combinations. This fixes a regression for pcd, which doesn't work after the constify patch. Fixes: 853fe1bf7554 ("cdrom: Make device operations read-only") Tested-by: Ondrej Zary Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/cdrom/cdrom.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 27a82a559ab94..933268b8d6a54 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -411,10 +411,10 @@ static int cdrom_get_disc_info(struct cdrom_device_info *cdi, * hack to have the capability flags defined const, while we can still * change it here without gcc complaining at every line. */ -#define ENSURE(call, bits) \ -do { \ - if (cdo->call == NULL) \ - *change_capability &= ~(bits); \ +#define ENSURE(cdo, call, bits) \ +do { \ + if (cdo->call == NULL) \ + WARN_ON_ONCE((cdo)->capability & (bits)); \ } while (0) /* @@ -590,7 +590,6 @@ int register_cdrom(struct cdrom_device_info *cdi) { static char banner_printed; const struct cdrom_device_ops *cdo = cdi->ops; - int *change_capability = (int *)&cdo->capability; /* hack */ cd_dbg(CD_OPEN, "entering register_cdrom\n"); @@ -602,16 +601,16 @@ int register_cdrom(struct cdrom_device_info *cdi) cdrom_sysctl_register(); } - ENSURE(drive_status, CDC_DRIVE_STATUS); + ENSURE(cdo, drive_status, CDC_DRIVE_STATUS); if (cdo->check_events == NULL && cdo->media_changed == NULL) - *change_capability = ~(CDC_MEDIA_CHANGED | CDC_SELECT_DISC); - ENSURE(tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY); - ENSURE(lock_door, CDC_LOCK); - ENSURE(select_speed, CDC_SELECT_SPEED); - ENSURE(get_last_session, CDC_MULTI_SESSION); - ENSURE(get_mcn, CDC_MCN); - ENSURE(reset, CDC_RESET); - ENSURE(generic_packet, CDC_GENERIC_PACKET); + WARN_ON_ONCE(cdo->capability & (CDC_MEDIA_CHANGED | CDC_SELECT_DISC)); + ENSURE(cdo, tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY); + ENSURE(cdo, lock_door, CDC_LOCK); + ENSURE(cdo, select_speed, CDC_SELECT_SPEED); + ENSURE(cdo, get_last_session, CDC_MULTI_SESSION); + ENSURE(cdo, get_mcn, CDC_MCN); + ENSURE(cdo, reset, CDC_RESET); + ENSURE(cdo, generic_packet, CDC_GENERIC_PACKET); cdi->mc_flags = 0; cdi->options = CDO_USE_FFLAGS; -- 2.20.1