lkml.org 
[lkml]   [2014]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mfd: core: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
Date
Since we cannot make sure the 'cell->num_resources' 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/mfd/mfd-core.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 892d343..54c7e35 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -89,6 +89,9 @@ static int mfd_add_device(struct device *parent, int id,
int ret = -ENOMEM;
int r;

+ if (!cell->num_resources)
+ return -EINVAL;
+
pdev = platform_device_alloc(cell->name, id + cell->id);
if (!pdev)
goto fail_alloc;
--
2.1.0.27.g96db324


\
 
 \ /
  Last update: 2014-09-18 11:01    [W:0.055 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site