Explorar o código

RDMA/nes: Add a check for strict_strtoul()

It should check if strict_strtoul() succeeds before using
'wqm_quanta_value'.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>

[ Convert to kstrtoul() directly while we're here.  - Roland ]

Signed-off-by: Roland Dreier <roland@purestorage.com>
Liu Yuan %!s(int64=14) %!d(string=hai) anos
pai
achega
52f81dbaf1
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      drivers/infiniband/hw/nes/nes.c

+ 3 - 1
drivers/infiniband/hw/nes/nes.c

@@ -1138,7 +1138,9 @@ static ssize_t nes_store_wqm_quanta(struct device_driver *ddp,
 	u32 i = 0;
 	struct nes_device *nesdev;
 
-	strict_strtoul(buf, 0, &wqm_quanta_value);
+	if (kstrtoul(buf, 0, &wqm_quanta_value) < 0)
+		return -EINVAL;
+
 	list_for_each_entry(nesdev, &nes_dev_list, list) {
 		if (i == ee_flsh_adapter) {
 			nesdev->nesadapter->wqm_quanta = wqm_quanta_value;