Commit 14b055f4 authored by Fabio Estevam's avatar Fabio Estevam Committed by Li Yang

soc: fsl: guts: Add a NULL check for devm_kasprintf()

devm_kasprintf() may fail, so we should better add a NULL check
and propagate an error on failure.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@nxp.com>
Acked-by: default avatarYangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: default avatarLi Yang <leoyang.li@nxp.com>
parent 6ea0acfd
...@@ -167,10 +167,16 @@ static int fsl_guts_probe(struct platform_device *pdev) ...@@ -167,10 +167,16 @@ static int fsl_guts_probe(struct platform_device *pdev)
} else { } else {
soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL, "QorIQ"); soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL, "QorIQ");
} }
if (!soc_dev_attr.family)
return -ENOMEM;
soc_dev_attr.soc_id = devm_kasprintf(dev, GFP_KERNEL, soc_dev_attr.soc_id = devm_kasprintf(dev, GFP_KERNEL,
"svr:0x%08x", svr); "svr:0x%08x", svr);
if (!soc_dev_attr.soc_id)
return -ENOMEM;
soc_dev_attr.revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d", soc_dev_attr.revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d",
(svr >> 4) & 0xf, svr & 0xf); (svr >> 4) & 0xf, svr & 0xf);
if (!soc_dev_attr.revision)
return -ENOMEM;
soc_dev = soc_device_register(&soc_dev_attr); soc_dev = soc_device_register(&soc_dev_attr);
if (IS_ERR(soc_dev)) if (IS_ERR(soc_dev))
......
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