Skip to contentSkip to conversation

staging: pi433: add missing call to cdev_del()

PATCH Superseded Michael Straube 2 participants 3 messages Nov 26, 2018 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: pi433: add missing call to cdev_del()

If cdev_add() fails, cdev_del() should be called.
Add the missing cdev_del() call as pointed out by
Dan Carpenter.

---
 drivers/staging/pi433/pi433_if.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/pi433/pi433_if.c +1 -0
index d72de2105053..abc98a544929 100644
@@ -1254,6 +1254,7 @@ static int pi433_probe(struct spi_device *spi)
 	retval = cdev_add(device->cdev, device->devt, 1);
 	if (retval) {
 		dev_dbg(device->dev, "register of cdev failed");
+		cdev_del(device->cdev);
 		goto cdev_failed;
 	}
 
Signature · 1 line
2.19.2
#2 lore raw
In reply to Dan Carpenter
Quoted 11 lines · Dan Carpenter

drivers/staging/pi433/pi433_if.c static int pi433_probe(struct spi_device *spi) · line 1258

Quoted 5 lines · Michael Straube
  	retval = cdev_add(device->cdev, device->devt, 1);
  	if (retval) {
  		dev_dbg(device->dev, "register of cdev failed");
drivers/staging/pi433/pi433_if.c +1 -0
+		cdev_del(device->cdev);
  		goto cdev_failed;

No no... That's not the right thing. Do "goto del_cdev;" and add a label at the end.

Quoted 6 lines

del_cdev:

	cdev_del(device->cdev);

regards,
dan carpenter

Ah ok, I thought about that but was not sure. Thanks, Michael

#1 lore raw
In reply to Michael Straube
Quoted 14 lines · Michael Straube

If cdev_add() fails, cdev_del() should be called.
Add the missing cdev_del() call as pointed out by
Dan Carpenter.

---
 drivers/staging/pi433/pi433_if.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/pi433/pi433_if.c +0 -0
index d72de2105053..abc98a544929 100644

drivers/staging/pi433/pi433_if.c static int pi433_probe(struct spi_device *spi) · line 1258

Quoted 5 lines
drivers/staging/pi433/pi433_if.c +1 -0
@@ -1254,6 +1254,7 @@ static int pi433_probe(struct spi_device *spi)
 	retval = cdev_add(device->cdev, device->devt, 1);
 	if (retval) {
 		dev_dbg(device->dev, "register of cdev failed");
+		cdev_del(device->cdev);
 		goto cdev_failed;

No no... That's not the right thing. Do "goto del_cdev;" and add a label at the end.

del_cdev:

	cdev_del(device->cdev);

regards,
dan carpenter