From: Claudiu Beznea Date: Thu, 15 Jun 2023 10:25:46 +0000 (+0300) Subject: misc: fastrpc: check return value of devm_kasprintf() X-Git-Tag: v6.6.7~2450^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af2e19d82a116bc622eea84c9faadd5f7e20bec4;p=platform%2Fkernel%2Flinux-starfive.git misc: fastrpc: check return value of devm_kasprintf() devm_kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script). Fixes: 3abe3ab3cdab ("misc: fastrpc: add secure domain support") Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20230615102546.581899-1-claudiu.beznea@microchip.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 37f32d2..9666d28 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -2225,6 +2225,9 @@ static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ct fdev->miscdev.fops = &fastrpc_fops; fdev->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "fastrpc-%s%s", domain, is_secured ? "-secure" : ""); + if (!fdev->miscdev.name) + return -ENOMEM; + err = misc_register(&fdev->miscdev); if (!err) { if (is_secured)