Return-Path: Received: from mail-by2nam03on0124.outbound.protection.outlook.com ([104.47.42.124]:23840 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934413AbeCCWhI (ORCPT ); Sat, 3 Mar 2018 17:37:08 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Bart Van Assche , Christoph Hellwig , Hannes Reinecke , Johannes Thumshirn , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 204/219] scsi: core: scsi_get_device_flags_keyed(): Always return device flags Date: Sat, 3 Mar 2018 22:29:55 +0000 Message-ID: <20180303222716.26640-204-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Bart Van Assche [ Upstream commit a44c9d36509c83cf64f33b93f6ab2e63822c01eb ] Since scsi_get_device_flags_keyed() callers do not check whether or not the returned value is an error code, change that function such that it returns a flags value even if the 'key' argument is invalid. Note: since commit 28a0bc4120d3 ("scsi: sd: Implement blacklist option for WRITE SAME w/ UNMAP") bit 31 is a valid device information flag so checking whether bit 31 is set in the return value is not sufficient to tell the difference between an error code and a flags value. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_devinfo.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 26e6b05d05fc..9545c40daa5e 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -596,17 +596,12 @@ int scsi_get_device_flags_keyed(struct scsi_device *s= dev, int key) { struct scsi_dev_info_list *devinfo; - int err; =20 devinfo =3D scsi_dev_info_list_find(vendor, model, key); if (!IS_ERR(devinfo)) return devinfo->flags; =20 - err =3D PTR_ERR(devinfo); - if (err !=3D -ENOENT) - return err; - - /* nothing found, return nothing */ + /* key or device not found: return nothing */ if (key !=3D SCSI_DEVINFO_GLOBAL) return 0; =20 --=20 2.14.1