public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] Staging: lustre: ptlrpc: signedness bug in high_priority_ratio_store()
@ 2015-06-05  9:22 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2015-06-05  9:22 UTC (permalink / raw)
  To: kernel-janitors

We want to store a non-negative int here.  The original code had a check
for unsigned long less than zero which is a mistake but also casting
from a positive long to an int can result in a negative number.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 1362160..0a53322 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -1035,9 +1035,9 @@ static ssize_t high_priority_ratio_store(struct kobject *kobj,
 	struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
 						  srv_kobj);
 	int rc;
-	unsigned long val;
+	int val;
 
-	rc = kstrtoul(buffer, 10, &val);
+	rc = kstrtoint(buffer, 10, &val);
 	if (rc < 0)
 		return rc;
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-05  9:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-05  9:22 [patch] Staging: lustre: ptlrpc: signedness bug in high_priority_ratio_store() Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox