Skip to content

Commit c72b9c3

Browse files
KunWuChantmlind
authored andcommitted
ARM: OMAP2+: Fix null pointer dereference and memory leak in omap_soc_device_init
kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. When 'soc_dev_attr->family' is NULL,it'll trigger the null pointer dereference issue, such as in 'soc_info_show'. And when 'soc_device_register' fails, it's necessary to release 'soc_dev_attr->family' to avoid memory leaks. Fixes: 6770b21 ("ARM: OMAP2+: Export SoC information to userspace") Signed-off-by: Kunwu Chan <[email protected]> Message-ID: <[email protected]> Signed-off-by: Tony Lindgren <[email protected]>
1 parent 1e5caee commit c72b9c3

File tree

1 file changed

+5
-0
lines changed
  • arch/arm/mach-omap2

1 file changed

+5
-0
lines changed

arch/arm/mach-omap2/id.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,11 +793,16 @@ void __init omap_soc_device_init(void)
793793

794794
soc_dev_attr->machine = soc_name;
795795
soc_dev_attr->family = omap_get_family();
796+
if (!soc_dev_attr->family) {
797+
kfree(soc_dev_attr);
798+
return;
799+
}
796800
soc_dev_attr->revision = soc_rev;
797801
soc_dev_attr->custom_attr_group = omap_soc_groups[0];
798802

799803
soc_dev = soc_device_register(soc_dev_attr);
800804
if (IS_ERR(soc_dev)) {
805+
kfree(soc_dev_attr->family);
801806
kfree(soc_dev_attr);
802807
return;
803808
}

0 commit comments

Comments
 (0)