Skip to content

Commit af2e19d

Browse files
claudiubezneagregkh
authored andcommitted
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: 3abe3ab ("misc: fastrpc: add secure domain support") Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lore.kernel.org/r/20230615102546.581899-1-claudiu.beznea@microchip.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent afc5fdd commit af2e19d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/misc/fastrpc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,6 +2225,9 @@ static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ct
22252225
fdev->miscdev.fops = &fastrpc_fops;
22262226
fdev->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "fastrpc-%s%s",
22272227
domain, is_secured ? "-secure" : "");
2228+
if (!fdev->miscdev.name)
2229+
return -ENOMEM;
2230+
22282231
err = misc_register(&fdev->miscdev);
22292232
if (!err) {
22302233
if (is_secured)

0 commit comments

Comments
 (0)