From patchwork Thu Jul 21 18:41:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9242319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D5C4360756 for ; Thu, 21 Jul 2016 18:43:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C85B41FF10 for ; Thu, 21 Jul 2016 18:43:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC38F27D64; Thu, 21 Jul 2016 18:43:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 715FF1FF10 for ; Thu, 21 Jul 2016 18:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753695AbcGUSnO (ORCPT ); Thu, 21 Jul 2016 14:43:14 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:34877 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752286AbcGUSmm (ORCPT ); Thu, 21 Jul 2016 14:42:42 -0400 Received: by mail-pa0-f65.google.com with SMTP id cf3so5604919pad.2; Thu, 21 Jul 2016 11:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=haexVu7NFCWsVZ7jDtOcArjabewWeQ/X5kofjgs7PUo=; b=F03g8G4LhLxT6f5crJLQLyWYHY+UDzSmJXO67nqc/ucEeLgl+6d4lrC4txCdUNklym vYRzrCUOMuYZN9FgI8i0MZt1LUziA7u9SNM+jJtHpyemFeH5U7YTqip7LLub3dKtwC12 GJdIui1hKY5ADkusUlgzobRw+3KvOvwRbAbx15HSC51NoB9u7uOiQBi++keGB/rKuLl/ 9IFn1r8f88TdZ2vV76Hc7nbT60nCwd6sfmwagGtj9Mm9rzVnuCLtvsAtQ9g+fTGtcOJA H9uPbVuhg0gwQeJS+kcHDAdGkyzmziBrxwGh4CKFTXzk+qB2A2sKU+Dg0U+jt0CmAfdG kemw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=haexVu7NFCWsVZ7jDtOcArjabewWeQ/X5kofjgs7PUo=; b=h5LtiRDgbal3Jvgx4XeoL0b3X2fz7W6cSAZkArSqHtmjvJUgVws5cQB5DPpw+9m+c/ 3qUYl8mypA1kEPGez9ZHBl4nNIO82LQu0w30hyu2jajlB/PjtijGGYd5DYYSjXdv1CRP jBSMXGtoQUUcHCRhUm3UoJ8NbibN9ZjORaIBSJS+LJqFFeiLj/N8WWAUnxjB+MYKck6p oLjhjletMHATidGK8SlEnWoOardBecyBxSxl4oSdyVK91g5oyuTHs4LzOSfICEi+jqG3 rn32vjuCHLtXDjmuXK98e0WO+vz+RfbdIQnrHK0ifVdtqaaaHoe7A/KiIXuA5cp3/iI0 yunQ== X-Gm-Message-State: ALyK8tIra4nFmdN/VqaD/i8yMyhOSug/v8Z5NpSZRDL0WxDFU0C9dmY3mWcFe4AXgvfTvg== X-Received: by 10.66.20.166 with SMTP id o6mr84680699pae.96.1469126561298; Thu, 21 Jul 2016 11:42:41 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id j7sm14002691paa.30.2016.07.21.11.42.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jul 2016 11:42:40 -0700 (PDT) From: tom.ty89@gmail.com X-Google-Original-From: me To: tj@kernel.org, hare@suse.de, sergei.shtylyov@cogentembedded.com, arnd@arndb.de Cc: sfr@canb.auug.org.au, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, Tom Yan Subject: [PATCH resend 4/5] libata-scsi: have all checks done before calling ata_mselect_*() Date: Fri, 22 Jul 2016 02:41:53 +0800 Message-Id: <14bd98eb08ddf86be28f558817bed3cd27c397cd.1469126217.git.tom.ty89@gmail.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tom Yan The one-page-at-a-time check in ata_scsi_mode_select_xlat() should be done before either of the ata_mselect_*() is called. Also updated the comment. We have more than one mode page that has changeable bit since commit 06dbde5f3a44 ("libata: Implement control mode page to select sense format"). Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 3c93341..6c424c5 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3837,6 +3837,12 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) if (pg_len > len) goto invalid_param_len; + /* + * Currently we only support setting one page at a time. + */ + if (len > pg_len) + goto invalid_param; + switch (pg) { case CACHE_MPAGE: if (ata_mselect_caching(qc, p, pg_len, &fp) < 0) { @@ -3855,13 +3861,6 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) goto invalid_param; } - /* - * Only one page has changeable data, so we only support setting one - * page at a time. - */ - if (len > pg_len) - goto invalid_param; - return 0; invalid_fld: