mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 08:26:59 +00:00
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>
This commit is contained in:
parent
ad16202de8
commit
533acc0e8d
1 changed files with 1 additions and 1 deletions
|
@ -236,7 +236,7 @@ int pwmchip_add(struct pwm_chip *chip)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!chip || !chip->dev || !chip->ops || !chip->ops->config ||
|
if (!chip || !chip->dev || !chip->ops || !chip->ops->config ||
|
||||||
!chip->ops->enable || !chip->ops->disable)
|
!chip->ops->enable || !chip->ops->disable || !chip->npwm)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&pwm_lock);
|
mutex_lock(&pwm_lock);
|
||||||
|
|
Loading…
Reference in a new issue