Commit 5c56f32e authored by Vasiliy Kulikov's avatar Vasiliy Kulikov Committed by Kevin Hilman

OMAP: PM: SmartReflex: fix potential NULL dereference

kzalloc() may fail, if so return -ENOMEM.  Also Walter Harms suggested
to use kasprintf() instead of kzalloc+strcpy+strcat.
Signed-off-by: default avatarVasiliy Kulikov <segoon@openwall.com>
Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent 8743410d
...@@ -260,9 +260,11 @@ static int sr_late_init(struct omap_sr *sr_info) ...@@ -260,9 +260,11 @@ static int sr_late_init(struct omap_sr *sr_info)
if (sr_class->class_type == SR_CLASS2 && if (sr_class->class_type == SR_CLASS2 &&
sr_class->notify_flags && sr_info->irq) { sr_class->notify_flags && sr_info->irq) {
name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL); name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
strcpy(name, "sr_"); if (name == NULL) {
strcat(name, sr_info->voltdm->name); ret = -ENOMEM;
goto error;
}
ret = request_irq(sr_info->irq, sr_interrupt, ret = request_irq(sr_info->irq, sr_interrupt,
0, name, (void *)sr_info); 0, name, (void *)sr_info);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment