diff options
author | Xiubo Li <Li.Xiubo@freescale.com> | 2014-05-19 03:13:45 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-05-26 11:37:04 -0400 |
commit | e12892070184ee782c207f09722a93d0236be955 (patch) | |
tree | 5fc0bb3d0295ad51878c6e5b05b54df92c88c026 /drivers/base | |
parent | c9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff) |
regmap: irq: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
Since we cannot make sure the 'chip->num_regs' will always be none zero
from the users, and then if 'chip->num_regs' equals to zero by mistake
or other reasons, the kzalloc() will return ZERO_SIZE_PTR, which equals
to ((void *)16).
So this patch fix this with just checking the 'chip->num_regs' before
calling kzalloc().
This also sorts the header files in alphabetical order at the same time.
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regmap-irq.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index edf88f20cbce..6299a50a5960 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c | |||
@@ -10,13 +10,13 @@ | |||
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/export.h> | ||
14 | #include <linux/device.h> | 13 | #include <linux/device.h> |
15 | #include <linux/regmap.h> | 14 | #include <linux/export.h> |
16 | #include <linux/irq.h> | ||
17 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <linux/irq.h> | ||
18 | #include <linux/irqdomain.h> | 17 | #include <linux/irqdomain.h> |
19 | #include <linux/pm_runtime.h> | 18 | #include <linux/pm_runtime.h> |
19 | #include <linux/regmap.h> | ||
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | 21 | ||
22 | #include "internal.h" | 22 | #include "internal.h" |
@@ -347,6 +347,9 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, | |||
347 | int ret = -ENOMEM; | 347 | int ret = -ENOMEM; |
348 | u32 reg; | 348 | u32 reg; |
349 | 349 | ||
350 | if (chip->num_regs <= 0) | ||
351 | return -EINVAL; | ||
352 | |||
350 | for (i = 0; i < chip->num_irqs; i++) { | 353 | for (i = 0; i < chip->num_irqs; i++) { |
351 | if (chip->irqs[i].reg_offset % map->reg_stride) | 354 | if (chip->irqs[i].reg_offset % map->reg_stride) |
352 | return -EINVAL; | 355 | return -EINVAL; |