Received: by 10.213.65.68 with SMTP id h4csp478485imn; Fri, 16 Mar 2018 09:00:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELtg2KQTXBu/n98triYj08EWzj3OJFmjyAZhCIc42f+03ORnPrP10YLUc5TixcxI1LNC8lpg X-Received: by 10.99.134.193 with SMTP id x184mr1878126pgd.324.1521216018533; Fri, 16 Mar 2018 09:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521216018; cv=none; d=google.com; s=arc-20160816; b=Ur0c263Vu45w4Ea+YCkBmkj48HOhhykEAmKhN7yR23VLA7Q89kTlruqt8ZjFBkff8p 4IQIPsKn3QpAopIh0FvDulbtRDoaek3mRq5EkaG62VIlDQEtUFoRfAzwHk62unAouiQE kkzj6X6KKzqTRbvPv83hQrN3iCUX71WtltiorWg4yia1ty6OPeCCLCMzHNQyzDCjPiii 9i/f/bcyl8tbkMncnG/mUjXkQuHToqSr4QxXMABVvspXfpgfwKOiLkkQTyhXwnfLHgg/ EPpAYcosrbSvyURRNpXANYWkd9J4Kth6FkE2ZOl9eELYOPaW+N7E3eyidRMueA5AiC+S SvXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ZV0NwuqYWQQ3BDmsxgRbyqTFjaHVTzDin/Nw/VTUc0U=; b=P5Q9NUKMdlvlIbeRXtQVgNpRtM+VFARybmtbpi7tdu9j+o9QBxsmI4LJCCR0phlraj 2uZq9lasGKAa6kLW7U992FePlz3QkRbHff3/0c1K8CxcbTAHwk76GREycdSNTsbLy1p6 mHGi3a0iVbVVCfnV7XkJYX7i2AiVorW7wypZ3UyclqaBnrSA7W8Ntzy5vGouw6O6ytVU 84dLTktG6ymgL2OQ9HK650O26KnC+hABUvBDKbFfGjUcI50DJxRt19n8LodkzoebxpEs xtHeCd0kZI8wVvMPThDjNwfxFHOnvthlrDhMOL+qZwEoxjP/tSeqy/26yMYxNX44/5/i qZog== ARC-Authentication-Results: i=1; mx.google.com; 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 b63si1715925pgc.72.2018.03.16.09.00.03; Fri, 16 Mar 2018 09:00:18 -0700 (PDT) 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; 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 S965171AbeCPP60 (ORCPT + 99 others); Fri, 16 Mar 2018 11:58:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45638 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965014AbeCPPnk (ORCPT ); Fri, 16 Mar 2018 11:43:40 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 554C4D13; Fri, 16 Mar 2018 15:43:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Christoph Hellwig , Hannes Reinecke , Johannes Thumshirn , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.15 099/128] scsi: core: scsi_get_device_flags_keyed(): Always return device flags Date: Fri, 16 Mar 2018 16:24:00 +0100 Message-Id: <20180316152341.489161158@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/scsi_devinfo.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -590,17 +590,12 @@ blist_flags_t scsi_get_device_flags_keye int key) { struct scsi_dev_info_list *devinfo; - int err; devinfo = scsi_dev_info_list_find(vendor, model, key); if (!IS_ERR(devinfo)) return devinfo->flags; - err = PTR_ERR(devinfo); - if (err != -ENOENT) - return err; - - /* nothing found, return nothing */ + /* key or device not found: return nothing */ if (key != SCSI_DEVINFO_GLOBAL) return 0;