Do not handle zero length buffer separately. Use kstrtouint() instead of sscanf(). Signed-off-by: Barnabás Pőcze <pobrn@xxxxxxxxxxxxxx> Reviewed-by: Hans de Goede <hdegoede@xxxxxxxxxx> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 677d4e10352e..cba3d9419f52 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -365,13 +365,13 @@ static ssize_t store_ideapad_cam(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret, state; + int ret; struct ideapad_private *priv = dev_get_drvdata(dev); + unsigned int state; - if (!count) - return 0; - if (sscanf(buf, "%i", &state) != 1) - return -EINVAL; + ret = kstrtouint(buf, 0, &state); + if (ret) + return ret; ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state); if (ret) return ret; @@ -398,14 +398,14 @@ static ssize_t store_ideapad_fan(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret, state; + int ret; struct ideapad_private *priv = dev_get_drvdata(dev); + unsigned int state; - if (!count) - return 0; - if (sscanf(buf, "%i", &state) != 1) - return -EINVAL; - if (state < 0 || state > 4 || state == 3) + ret = kstrtouint(buf, 0, &state); + if (ret) + return ret; + if (state > 4 || state == 3) return -EINVAL; ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state); if (ret) -- 2.30.0