]> Git Repo - linux.git/commitdiff
regmap: irq: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
authorXiubo Li <[email protected]>
Mon, 19 May 2014 07:13:45 +0000 (15:13 +0800)
committerMark Brown <[email protected]>
Mon, 26 May 2014 15:37:04 +0000 (16:37 +0100)
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 <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
drivers/base/regmap/regmap-irq.c

index edf88f20cbce8df434058b18f772393e781b4547..6299a50a59607f6d5598eac804817cef47e8c106 100644 (file)
  * published by the Free Software Foundation.
  */
 
-#include <linux/export.h>
 #include <linux/device.h>
-#include <linux/regmap.h>
-#include <linux/irq.h>
+#include <linux/export.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/pm_runtime.h>
+#include <linux/regmap.h>
 #include <linux/slab.h>
 
 #include "internal.h"
@@ -347,6 +347,9 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
        int ret = -ENOMEM;
        u32 reg;
 
+       if (chip->num_regs <= 0)
+               return -EINVAL;
+
        for (i = 0; i < chip->num_irqs; i++) {
                if (chip->irqs[i].reg_offset % map->reg_stride)
                        return -EINVAL;
This page took 0.056522 seconds and 4 git commands to generate.