Skip to contentSkip to conversation

Staging: lustre: ptlrpc: signedness bug in high_priority_ratio_store()

PATCH New Dan Carpenter 1 participant 1 message Jun 5, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: lustre: ptlrpc: signedness bug in high_priority_ratio_store()

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.

drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +2 -2
index 1362160..0a53322 100644
@@ -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;