MFD: prevent null pointer dereference in mfd_add_device
PATCH 1/1 MFD: prevent null pointer dereference in mfd_add_device
If a driver calls mfd_add_device with a NULL argument for the mem_base resource we will end up dereferencing it without checking for its validity here:
res[r].start = mem_base->start cell->resources[r].start; (line 53 of mfd-core.c)
This patch adds the checking on the mem_base argument and bails out accordingly if it is NULL.
---
drivers/mfd/mfd-core.c +2 -0
@@ -49,6 +49,8 @@ static int mfd_add_device(struct device *parent, int id,/* Find out base to use */ if (cell->resources[r].flags &IORESOURCE_MEM ) { +if (!mem_base) + goto fail_res; res[r].parent = mem_base; res[r].start = mem_base->start + cell->resources[r].start;
Hi Samuel,
I just saw that your for-next branch contains the proper fix, this patch can be discarded.
Quoted 25 lines · Florian Fainelli
If a driver calls
mfd_add_devicewith a NULL argument for themem_base
resource we will end up dereferencing it without checking for its validity
here: res[r].start =mem_base->startcell->resources[r].start; (line 53 ofmfd-core.c)This patch adds the checking on the
mem_baseargument and bails out
accordingly if it is NULL.Signed-off-by Florian Fainelli <[email protected]>---
drivers/mfd/mfd-core.c +2
-0@@ -49,6 +49,8 @@ static int mfd_add_device(struct device *parent, int id,/* Find out base to use */ if (cell->resources[r].flags &IORESOURCE_MEM ) { +if (!mem_base) + goto fail_res; res[r].parent = mem_base; res[r].start = mem_base->start + cell->resources[r].start;