UPSTREAM: pwm: Improve args checking in pwm_apply_state()
[firefly-linux-kernel-4.4.55.git] / include / linux / pwm.h
index d40c03e5afe3c11ed2736635f3b5f8b325c1df5f..beeecccfe40ecec88f0f72d55e2c5e26c82408b5 100644 (file)
@@ -235,6 +235,9 @@ static inline int pwm_config(struct pwm_device *pwm, int duty_ns,
        if (!pwm)
                return -EINVAL;
 
+       if (duty_ns < 0 || period_ns < 0)
+               return -EINVAL;
+
        pwm_get_state(pwm, &state);
        if (state.duty_cycle == duty_ns && state.period == period_ns)
                return 0;