diff options
author | Xiubo Li <Li.Xiubo@freescale.com> | 2014-08-18 05:08:44 -0400 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2014-08-25 08:38:12 -0400 |
commit | 533acc0e8df7d6553f11cf91c177211cb6037968 (patch) | |
tree | 812cd4e995141cfe2c1ce2533f52f4017d5af6b1 /drivers/pwm/core.c | |
parent | ad16202de8d884c10ef7637ea3982953519c2418 (diff) |
pwm: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
Since we cannot make sure the 'chip->npwm' will always be none zero here,
and then if either equal to zero, the kzalloc() will return ZERO_SIZE_PTR,
which equals to ((void *)16).
So this patch fix this with just doing the zero check before calling kzalloc().
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/core.c')
-rw-r--r-- | drivers/pwm/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index d2c35920ff08..8c748b17f416 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c | |||
@@ -236,7 +236,7 @@ int pwmchip_add(struct pwm_chip *chip) | |||
236 | int ret; | 236 | int ret; |
237 | 237 | ||
238 | if (!chip || !chip->dev || !chip->ops || !chip->ops->config || | 238 | if (!chip || !chip->dev || !chip->ops || !chip->ops->config || |
239 | !chip->ops->enable || !chip->ops->disable) | 239 | !chip->ops->enable || !chip->ops->disable || !chip->npwm) |
240 | return -EINVAL; | 240 | return -EINVAL; |
241 | 241 | ||
242 | mutex_lock(&pwm_lock); | 242 | mutex_lock(&pwm_lock); |