Skip to contentSkip to conversation

char: pcmcia: scr24x_cs: Fix failure handling Handled failure cases of pcmcia_enable_device() and device_create()

PATCH In review [email protected] 3 participants 6 messages May 23, 2021 – May 24, 2021 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 char: pcmcia: scr24x_cs: Fix failure handling Handled failure cases of pcmcia_enable_device() and device_create()

From: Nijam Haider <[email protected]>

---
 drivers/char/pcmcia/scr24x_cs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/char/pcmcia/scr24x_cs.c +10 -1
index 47feb39..cad1990 100644
@@ -233,6 +233,7 @@ static int scr24x_probe(struct pcmcia_device *link)
 {
 	struct scr24x_dev *dev;
 	int ret;
+       struct device *dev_ret;
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
@@ -272,12 +273,20 @@ static int scr24x_probe(struct pcmcia_device *link)
 
 	ret = pcmcia_enable_device(link);
 	if (ret < 0) {
+	        cdev_del(&dev->c_dev);
 		pcmcia_disable_device(link);
 		goto err;
 	}
 
-	device_create(scr24x_class, NULL, MKDEV(MAJOR(scr24x_devt), dev->devno),
+	dev_ret = device_create(scr24x_class, NULL, MKDEV(MAJOR(scr24x_devt), dev->devno),
 		      NULL, "scr24x%d", dev->devno);
+        if (IS_ERR(dev_ret)) {
+                printk(KERN_ERR "device_create failed for %d\n",
+                               dev->devno);
+                cdev_del(&dev->c_dev);
+                pcmcia_disable_device(link);
+                goto err;
+       }
 
 	dev_info(&link->dev, "SCR24x Chip Card Interface\n");
 	return 0;
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 char: pcmcia: scr24x_cs: Fix redundant fops Removed redundant fops assignment, which was already done in cdev_init()

From: Nijam Haider <[email protected]>

---
 drivers/char/pcmcia/scr24x_cs.c | 1 -
 1 file changed, 1 deletion(-)
drivers/char/pcmcia/scr24x_cs.c +0 -1
index cad1990..0265d72 100644
@@ -266,7 +266,6 @@ static int scr24x_probe(struct pcmcia_device *link)
 
 	cdev_init(&dev->c_dev, &scr24x_fops);
 	dev->c_dev.owner = THIS_MODULE;
-	dev->c_dev.ops = &scr24x_fops;
 	ret = cdev_add(&dev->c_dev, MKDEV(MAJOR(scr24x_devt), dev->devno), 1);
 	if (ret < 0)
 		goto err;
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH 2/2] char: pcmcia: scr24x_cs: Fix redundant fops Removed redundant fops assignment, which was already done in cdev_init()

Quoted 6 lines · On Sun, May 23, 2021 at 08:41:11PM +0530, [email protected] wrote:

From: Nijam Haider <[email protected]>

---
 drivers/char/pcmcia/scr24x_cs.c | 1 -
 1 file changed, 1 deletion(-)

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- You did not specify a description of why the patch is needed, or possibly, any description at all, in the email body. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what is needed in order to properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg, and everyone else, to know what this patch is all about. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what a proper Subject: line should look like.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot

#3 lore raw

Re: [PATCH 2/2] char: pcmcia: scr24x_cs: Fix redundant fops Removed redundant fops assignment, which was already done in cdev_init()

In reply to [email protected]
Quoted 2 lines · On Sun, May 23, 2021 at 08:41:11PM +0530, [email protected] wrote:

From: Nijam Haider <[email protected]>

Thank you for this. Needs another spin though:

Quoted 1 line

Subject: [PATCH 2/2] char: pcmcia: scr24x_cs: Fix redundant fops Removed

                                                                  ^

It seems like you accidentally removed a line break here ---------|, squishing the subject and patch description together.

Quoted 1 line

redundant fops assignment, which was already done in cdev_init()

Regards,
Lubo

Quoted 20 lines
---
 drivers/char/pcmcia/scr24x_cs.c | 1 -
 1 file changed, 1 deletion(-)
drivers/char/pcmcia/scr24x_cs.c +0 -1
index cad1990..0265d72 100644
@@ -266,7 +266,6 @@ static int scr24x_probe(struct pcmcia_device *link)
 
 	cdev_init(&dev->c_dev, &scr24x_fops);
 	dev->c_dev.owner = THIS_MODULE;
-	dev->c_dev.ops = &scr24x_fops;
 	ret = cdev_add(&dev->c_dev, MKDEV(MAJOR(scr24x_devt), dev->devno), 1);
 	if (ret < 0)
 		goto err;
Signature · 1 line
2.7.4
#5 lore raw
In reply to [email protected]
Quoted 2 lines

Subject: Re: [PATCH 1/2] char: pcmcia: scr24x_cs: Fix failure handling
Handled failure cases of pcmcia_enable_device() and device_create()

Here you also manaded to squish the subject line and the patch description together. Please break them into two.

Quoted 12 lines · On Sun, May 23, 2021 at 08:41:10PM +0530, [email protected] wrote:

From: Nijam Haider <[email protected]>

---
 drivers/char/pcmcia/scr24x_cs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/char/pcmcia/scr24x_cs.c +0 -0
index 47feb39..cad1990 100644

drivers/char/pcmcia/scr24x_cs.c static int scr24x_probe(struct pcmcia_device *link) · line 236

Quoted 4 lines
drivers/char/pcmcia/scr24x_cs.c +1 -0
@@ -233,6 +233,7 @@ static int scr24x_probe(struct pcmcia_device *link)
 {
 	struct scr24x_dev *dev;
 	int ret;
+       struct device *dev_ret;

Looks like a whitespace error here?

drivers/char/pcmcia/scr24x_cs.c static int scr24x_probe(struct pcmcia_device *link) · line 276

Quoted 7 lines
drivers/char/pcmcia/scr24x_cs.c +1 -0
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
@@ -272,12 +273,20 @@ static int scr24x_probe(struct pcmcia_device *link)
 
 	ret = pcmcia_enable_device(link);
 	if (ret < 0) {
+	        cdev_del(&dev->c_dev);

Also here? (a tab followed by spaces).

Quoted 4 lines
drivers/char/pcmcia/scr24x_cs.c +0 -0
 		pcmcia_disable_device(link);
 		goto err;
 	}
 

drivers/char/pcmcia/scr24x_cs.c static int scr24x_probe(struct pcmcia_device *link) · line 289

Quoted 10 lines
drivers/char/pcmcia/scr24x_cs.c +8 -1
-	device_create(scr24x_class, NULL, MKDEV(MAJOR(scr24x_devt), dev->devno),
+	dev_ret = device_create(scr24x_class, NULL, MKDEV(MAJOR(scr24x_devt), dev->devno),
 		      NULL, "scr24x%d", dev->devno);
+        if (IS_ERR(dev_ret)) {
+                printk(KERN_ERR "device_create failed for %d\n",
+                               dev->devno);
+                cdev_del(&dev->c_dev);
+                pcmcia_disable_device(link);
+                goto err;
+       }

...and also here.

In general, please try keeping the formatting consistent with the rest of the file. Indentation is generally done with tabs.

drivers/char/pcmcia/scr24x_cs.c static int scr24x_probe(struct pcmcia_device *link) · line 292

Quoted 2 lines
drivers/char/pcmcia/scr24x_cs.c +0 -0
 	dev_info(&link->dev, "SCR24x Chip Card Interface\n");
 	return 0;

Thank you,
Lubo