* [PATCH] pwm: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
@ 2014-08-18 9:08 Xiubo Li
2014-08-25 12:38 ` Thierry Reding
0 siblings, 1 reply; 2+ messages in thread
From: Xiubo Li @ 2014-08-18 9:08 UTC (permalink / raw)
To: thierry.reding, linux-pwm; +Cc: Xiubo Li
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>
---
drivers/pwm/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 4b66bf0..786d0f1 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -236,7 +236,7 @@ int pwmchip_add(struct pwm_chip *chip)
int ret;
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;
mutex_lock(&pwm_lock);
--
1.8.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pwm: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
2014-08-18 9:08 [PATCH] pwm: Fix possible ZERO_SIZE_PTR pointer dereferencing error Xiubo Li
@ 2014-08-25 12:38 ` Thierry Reding
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2014-08-25 12:38 UTC (permalink / raw)
To: Xiubo Li; +Cc: linux-pwm
[-- Attachment #1: Type: text/plain, Size: 508 bytes --]
On Mon, Aug 18, 2014 at 05:08:44PM +0800, Xiubo Li wrote:
> 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>
> ---
> drivers/pwm/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-25 12:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-18 9:08 [PATCH] pwm: Fix possible ZERO_SIZE_PTR pointer dereferencing error Xiubo Li
2014-08-25 12:38 ` Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).