From patchwork Fri Mar 11 00:45:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 8561121 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B70B5C0554 for ; Fri, 11 Mar 2016 00:45:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FB0120386 for ; Fri, 11 Mar 2016 00:45:49 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CF9D20382 for ; Fri, 11 Mar 2016 00:45:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2AB201A1F61; Thu, 10 Mar 2016 16:46:02 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id 7374A1A1F64 for ; Thu, 10 Mar 2016 16:46:00 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 10 Mar 2016 16:45:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,318,1455004800"; d="scan'208";a="907552035" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.14]) by orsmga001.jf.intel.com with ESMTP; 10 Mar 2016 16:45:42 -0800 Subject: [ndctl PATCH 1/3] ndctl: fix ndctl_bus_cmd_new_ars_status() input validation From: Dan Williams To: linux-nvdimm@lists.01.org Date: Thu, 10 Mar 2016 16:45:16 -0800 Message-ID: <20160311004516.27582.37530.stgit@dwillia2-desk3.jf.intel.com> In-Reply-To: <20160311004511.27582.63304.stgit@dwillia2-desk3.jf.intel.com> References: <20160311004511.27582.63304.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Check that ars_status, rather than ars_cap, commands are supported and validate that the reference ars_cap passed in is indeed and ars_cap command. Cc: Vishal Verma Signed-off-by: Dan Williams Reviewed-by: Vishal Verma --- lib/libndctl-ars.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libndctl-ars.c b/lib/libndctl-ars.c index ad85191898d4..63d0e5544a36 100644 --- a/lib/libndctl-ars.c +++ b/lib/libndctl-ars.c @@ -55,7 +55,7 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_start(struct ndctl_cmd *ars dbg(ctx, "unsupported cmd\n"); return NULL; } - if (ars_cap->status != 0) { + if (ars_cap->type != ND_CMD_ARS_CAP || ars_cap->status != 0) { dbg(ctx, "expected sucessfully completed ars_cap command\n"); return NULL; } @@ -94,11 +94,11 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *ar struct ndctl_cmd *cmd; size_t size; - if (!ndctl_bus_is_cmd_supported(bus, ND_CMD_ARS_CAP)) { + if (!ndctl_bus_is_cmd_supported(bus, ND_CMD_ARS_STATUS)) { dbg(ctx, "unsupported cmd\n"); return NULL; } - if (ars_cap->status != 0) { + if (ars_cap->type != ND_CMD_ARS_CAP || ars_cap->status != 0) { dbg(ctx, "expected sucessfully completed ars_cap command\n"); return NULL; }