[PATCH] char: warnning msg for devm_snprintf failed to allocate memory.

From: Tom Hu
Date: Wed Jan 24 2024 - 00:29:21 EST


From: huxiaoying <huxiaoying@xxxxxxxxxx>

Signed-off-by: Tom Hu <huxiaoying@xxxxxxxxxx>
---
drivers/char/ipmi/ipmb_dev_int.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/char/ipmi/ipmb_dev_int.c b/drivers/char/ipmi/ipmb_dev_int.c
index 49100845fcb7..8e703ecb27c3 100644
--- a/drivers/char/ipmi/ipmb_dev_int.c
+++ b/drivers/char/ipmi/ipmb_dev_int.c
@@ -321,6 +321,9 @@ static int ipmb_probe(struct i2c_client *client)
ipmb_dev->miscdev.name = devm_kasprintf(&client->dev, GFP_KERNEL,
"%s%d", "ipmb-",
client->adapter->nr);
+ if (!ipmb_dev->miscdev.name)
+ pr_warn("Failed to allocate mem to miscdev.name\n");
+
ipmb_dev->miscdev.fops = &ipmb_fops;
ipmb_dev->miscdev.parent = &client->dev;
ret = misc_register(&ipmb_dev->miscdev);
--
2.25.1