All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] char: pcmcia: cm4000_cs: Fix failure handling
@ 2021-05-24 23:02 nizamhaider786
  2021-05-24 23:02 ` [PATCH v2 2/2] char: pcmcia: cm4040_cs: " nizamhaider786
  2021-05-27 12:45 ` [PATCH v2 1/2] char: pcmcia: cm4000_cs: " Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: nizamhaider786 @ 2021-05-24 23:02 UTC (permalink / raw)
  To: laforge; +Cc: arnd, gregkh, linux-kernel, Nijam Haider

From: Nijam Haider <nizamhaider786@gmail.com>

Handled failure cases of device_create()

Signed-off-by: Nijam Haider <nizamhaider786@gmail.com>
---
V1 -> V2: Added description and changelog
---
 drivers/char/pcmcia/cm4000_cs.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 89681f07bc78..1ed4eac6b8ef 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1783,6 +1783,7 @@ static int cm4000_probe(struct pcmcia_device *link)
 {
 	struct cm4000_dev *dev;
 	int i, ret;
+	struct device *dev_ret;
 
 	for (i = 0; i < CM4000_MAX_DEV; i++)
 		if (dev_table[i] == NULL)
@@ -1814,8 +1815,14 @@ static int cm4000_probe(struct pcmcia_device *link)
 		return ret;
 	}
 
-	device_create(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
-
+	dev_ret = device_create(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
+	if (IS_ERR(dev_ret)) {
+		dev_err(&link->dev, "device_create failed for %d\n", i);
+		cm4000_release(link);
+		dev_table[i] = NULL;
+		kfree(dev);
+		return -ENODEV;
+	}
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-27 12:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 23:02 [PATCH v2 1/2] char: pcmcia: cm4000_cs: Fix failure handling nizamhaider786
2021-05-24 23:02 ` [PATCH v2 2/2] char: pcmcia: cm4040_cs: " nizamhaider786
2021-05-27 12:45   ` Greg KH
2021-05-27 12:45 ` [PATCH v2 1/2] char: pcmcia: cm4000_cs: " Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.