[PATCH] char: xilinx_hwicap: check device_create() return value
From: Linkai Gong
Date: Tue Aug 11 2026 - 03:17:32 EST
device_create() can fail, but the driver ignored the return value and
still reported probe success. That leaves a registered char device
without its /dev node.
Check the return value, report the error, and delete the cdev on
failure.
Fixes: ef141a0bb0dc ("[POWERPC] Xilinx: hwicap driver")
Signed-off-by: Linkai Gong <gonglinkai@xxxxxxxxxx>
---
drivers/char/xilinx_hwicap/xilinx_hwicap.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 34a345dc5e72..338588b7bf08 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -660,9 +660,17 @@ static int hwicap_setup(struct platform_device *pdev, int id,
goto failed;
}
- device_create(&icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id);
+ retval = PTR_ERR_OR_ZERO(device_create(&icap_class, dev, devt, NULL,
+ "%s%d", DRIVER_NAME, id));
+ if (retval) {
+ dev_err(dev, "device_create() failed: %d\n", retval);
+ goto failed_cdev;
+ }
+
return 0; /* success */
+ failed_cdev:
+ cdev_del(&drvdata->cdev);
failed:
mutex_lock(&icap_sem);
probed_devices[id] = 0;
--
2.25.1