> -----Original Message----- > From: Fabio Estevam [mailto:[email protected]] > Sent: 2018年1月6日 21:23 > To: Leo Li <[email protected]> > Cc: [email protected]; Y.b. Lu <[email protected]>; Fabio > Estevam <[email protected]> > Subject: [PATCH] soc/fsl/guts: Add a NULL check for devm_kasprintf() > > From: Fabio Estevam <[email protected]> > > devm_kasprintf() may fail, so we should better add a NULL check and > propagate an error on failure. > > Signed-off-by: Fabio Estevam <[email protected]>
[Y.b. Lu] It makes sense. Acked-by: Yangbo Lu <[email protected]> > --- > drivers/soc/fsl/guts.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index > d89a6a8..82251b4 100644 > --- a/drivers/soc/fsl/guts.c > +++ b/drivers/soc/fsl/guts.c > @@ -167,10 +167,16 @@ static int fsl_guts_probe(struct platform_device > *pdev) > } else { > 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, > "svr:0x%08x", svr); > + if (!soc_dev_attr.soc_id) > + return -ENOMEM; > soc_dev_attr.revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d", > (svr >> 4) & 0xf, svr & 0xf); > + if (!soc_dev_attr.revision) > + return -ENOMEM; > > soc_dev = soc_device_register(&soc_dev_attr); > if (IS_ERR(soc_dev)) > -- > 2.7.4
