[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210523193029.3178-2-nizamhaider786@gmail.com>
Date: Mon, 24 May 2021 01:00:29 +0530
From: nizamhaider786@...il.com
To: laforge@...monks.org
Cc: arnd@...db.de, gregkh@...uxfoundation.org,
linux-kernel@...r.kernel.org,
Nijam Haider <nizamhaider786@...il.com>
Subject: [PATCH 2/2] char: pcmcia: cm4040_cs: Fix failure handling Handled failure cases of device_create()
From: Nijam Haider <nizamhaider786@...il.com>
Signed-off-by: Nijam Haider <nizamhaider786@...il.com>
---
drivers/char/pcmcia/cm4040_cs.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index d5e4360..30bb977 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -558,6 +558,7 @@ static void reader_release(struct pcmcia_device *link)
static int reader_probe(struct pcmcia_device *link)
{
struct reader_dev *dev;
+ struct device *dev_ret;
int i, ret;
for (i = 0; i < CM_MAX_DEV; i++) {
@@ -593,8 +594,15 @@ static int reader_probe(struct pcmcia_device *link)
return ret;
}
- device_create(cmx_class, NULL, MKDEV(major, i), NULL, "cmx%d", i);
-
+ dev_ret = device_create(cmx_class, NULL, MKDEV(major, i), NULL, "cmx%d", i);
+ if (IS_ERR(dev_ret)) {
+ printk(KERN_ERR "device_create failed for %d\n",
+ i);
+ reader_release(link);
+ dev_table[i] = NULL;
+ kfree(dev);
+ return -ENODEV;
+ }
return 0;
}
--
2.7.4
Powered by blists - more mailing lists