drm/amdgpu: replace simple_strtol() by kstrtou32()
authorWang Xiayang <xywang.sjtu@sjtu.edu.cn>
Mon, 15 Jul 2019 08:53:01 +0000 (16:53 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 16 Jul 2019 18:09:09 +0000 (13:09 -0500)
The simple_strtol() function is deprecated. kstrto[l,u32]() is
the correct replacement as it can properly handle overflows.

This patch replaces the deprecated simple_strtol() use introduced recently.
As clk is of type uint32_t, we are safe to use kstrtou32().

It is also safe to return zero on string parsing error,
similar to the case of returning zero if buf is empty in parse_clk().

Fixes: bb5a2bdf36a8 ("drm/amdgpu: support dpm level modification under virtualization v3")
Signed-off-by: Wang Xiayang <xywang.sjtu@sjtu.edu.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c

index 07a7e3820b7ba6006d1cb381c91b0e3ceaab302a..59dd204498c52dff4bc1d1e62ecefa34e419d87f 100644 (file)
@@ -390,7 +390,8 @@ static uint32_t parse_clk(char *buf, bool min)
                 if (!ptr)
                         break;
                 ptr+=2;
-                clk = simple_strtoul(ptr, NULL, 10);
+               if (kstrtou32(ptr, 10, &clk))
+                       return 0;
         } while (!min);
 
         return clk * 100;