diff mbox

mtd: physmap_of: Fix map name when "linux, mtd-name" is absent

Message ID 1359542256-19135-1-git-send-email-pawel.moll@arm.com
State New, archived
Headers show

Commit Message

Pawel Moll Jan. 30, 2013, 10:37 a.m. UTC
Commit d68cbdd4fb04d2b756ad53c22f36943167b16340 "mtd: physmap_of:
allow to specify the mtd name for retro compatiblity" introduced
a "linux,mtd-name" property to override map names, but when
this property is absent (so of_property_read_string() returns
value != 0) an uninitialized value is used (as mtd_name is not
set). This may lead to kernel oopses when the name is
derefernced, eg:

Unable to handle kernel NULL pointer dereference at virtual address 00000001
pgd = 80004000
[00000001] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 3    Not tainted  (3.8.0-rc5+ #644)
PC is at strcmp+0x4/0x30
LR is at parse_cmdline_partitions+0x54/0x2f8

Fixed by initializing the variable to NULL.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 drivers/mtd/maps/physmap_of.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Florian Fainelli Jan. 30, 2013, 11:07 a.m. UTC | #1
Hello

On 01/30/2013 11:37 AM, Pawel Moll wrote:
> Commit d68cbdd4fb04d2b756ad53c22f36943167b16340 "mtd: physmap_of:
> allow to specify the mtd name for retro compatiblity" introduced
> a "linux,mtd-name" property to override map names, but when
> this property is absent (so of_property_read_string() returns
> value != 0) an uninitialized value is used (as mtd_name is not
> set). This may lead to kernel oopses when the name is
> derefernced, eg:
>
> Unable to handle kernel NULL pointer dereference at virtual address 00000001
> pgd = 80004000
> [00000001] *pgd=00000000
> Internal error: Oops: 5 [#1] SMP ARM
> Modules linked in:
> CPU: 3    Not tainted  (3.8.0-rc5+ #644)
> PC is at strcmp+0x4/0x30
> LR is at parse_cmdline_partitions+0x54/0x2f8
>
> Fixed by initializing the variable to NULL.

This is the 3rd time such a patch is submitted.

1358446932-7238-1-git-send-email-stef.van.os@prodrive.nl
df9da712b775781366ae23aac28ed20849b4e4d3.1356260943.git.baruch@tkos.co.il

Fortunately it is now in linux-mtd:
http://git.infradead.org/linux-mtd.git/commit/7dfe4be351e81656ca1068e5d4ead235c7ba94b1

>
> Signed-off-by: Pawel Moll <pawel.moll@arm.com>
> ---
>   drivers/mtd/maps/physmap_of.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
> index 67cc73c..7901d72 100644
> --- a/drivers/mtd/maps/physmap_of.c
> +++ b/drivers/mtd/maps/physmap_of.c
> @@ -170,7 +170,7 @@ static int of_flash_probe(struct platform_device *dev)
>   	resource_size_t res_size;
>   	struct mtd_part_parser_data ppdata;
>   	bool map_indirect;
> -	const char *mtd_name;
> +	const char *mtd_name = NULL;
>
>   	match = of_match_device(of_flash_match, &dev->dev);
>   	if (!match)
>
Pawel Moll Jan. 30, 2013, 11:30 a.m. UTC | #2
On Wed, 2013-01-30 at 11:07 +0000, Florian Fainelli wrote:
> > Commit d68cbdd4fb04d2b756ad53c22f36943167b16340 "mtd: physmap_of:
> > allow to specify the mtd name for retro compatiblity" introduced
> > a "linux,mtd-name" property to override map names, but when
> > this property is absent (so of_property_read_string() returns
> > value != 0) an uninitialized value is used (as mtd_name is not
> > set). This may lead to kernel oopses when the name is
> > derefernced, eg:
> >
> > Unable to handle kernel NULL pointer dereference at virtual address 00000001
> > pgd = 80004000
> > [00000001] *pgd=00000000
> > Internal error: Oops: 5 [#1] SMP ARM
> > Modules linked in:
> > CPU: 3    Not tainted  (3.8.0-rc5+ #644)
> > PC is at strcmp+0x4/0x30
> > LR is at parse_cmdline_partitions+0x54/0x2f8
> >
> > Fixed by initializing the variable to NULL.
> 
> This is the 3rd time such a patch is submitted.
> 
> 1358446932-7238-1-git-send-email-stef.van.os@prodrive.nl
> df9da712b775781366ae23aac28ed20849b4e4d3.1356260943.git.baruch@tkos.co.il
> 
> Fortunately it is now in linux-mtd:
> http://git.infradead.org/linux-mtd.git/commit/7dfe4be351e81656ca1068e5d4ead235c7ba94b1

Great, thanks for letting me know!

Pawel
diff mbox

Patch

diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 67cc73c..7901d72 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -170,7 +170,7 @@  static int of_flash_probe(struct platform_device *dev)
 	resource_size_t res_size;
 	struct mtd_part_parser_data ppdata;
 	bool map_indirect;
-	const char *mtd_name;
+	const char *mtd_name = NULL;
 
 	match = of_match_device(of_flash_match, &dev->dev);
 	if (!match)