diff mbox

[ndctl,1/3] ndctl: fix ndctl_bus_cmd_new_ars_status() input validation

Message ID 20160311004516.27582.37530.stgit@dwillia2-desk3.jf.intel.com (mailing list archive)
State Accepted
Commit d0dffb981360
Headers show

Commit Message

Dan Williams March 11, 2016, 12:45 a.m. UTC
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 <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 lib/libndctl-ars.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Verma, Vishal L March 11, 2016, 1:17 a.m. UTC | #1
On Thu, 2016-03-10 at 16:45 -0800, Dan Williams wrote:
> 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


s/and/an/

> command.

> 

> Cc: Vishal Verma <vishal.l.verma@intel.com>

> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

> ---

>  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)) {


Good catch :)

>  		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;

>  	}

> 


Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
diff mbox

Patch

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;
 	}