pwm: Check for negative duty-cycle and period
[linux-block.git] / drivers / pwm / core.c
index 92b1782d0d8ef7e25ca08796db6939d7f05de9d8..f5acdaa527077bc1e6e4bd8f67a52b21c5310dfb 100644 (file)
@@ -371,7 +371,7 @@ EXPORT_SYMBOL_GPL(pwm_free);
  */
 int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
 {
-       if (!pwm || period_ns == 0 || duty_ns > period_ns)
+       if (!pwm || duty_ns < 0 || period_ns <= 0 || duty_ns > period_ns)
                return -EINVAL;
 
        return pwm->chip->ops->config(pwm->chip, pwm, duty_ns, period_ns);