All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: pi433: add missing call to cdev_del()
@ 2018-11-26 17:53 Michael Straube
  2018-11-26 18:01 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Straube @ 2018-11-26 17:53 UTC (permalink / raw)
  To: gregkh; +Cc: linux, dan.carpenter, devel, linux-kernel, Michael Straube

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

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/pi433/pi433_if.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d72de2105053..abc98a544929 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -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;
 	}
 
-- 
2.19.2


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

* Re: [PATCH] staging: pi433: add missing call to cdev_del()
  2018-11-26 17:53 [PATCH] staging: pi433: add missing call to cdev_del() Michael Straube
@ 2018-11-26 18:01 ` Dan Carpenter
  2018-11-26 18:12   ` Michael Straube
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-11-26 18:01 UTC (permalink / raw)
  To: Michael Straube; +Cc: gregkh, linux, devel, linux-kernel

On Mon, Nov 26, 2018 at 06:53:55PM +0100, Michael Straube wrote:
> If cdev_add() fails, cdev_del() should be called.
> Add the missing cdev_del() call as pointed out by
> Dan Carpenter.
> 
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
>  drivers/staging/pi433/pi433_if.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
> index d72de2105053..abc98a544929 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -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


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

* Re: [PATCH] staging: pi433: add missing call to cdev_del()
  2018-11-26 18:01 ` Dan Carpenter
@ 2018-11-26 18:12   ` Michael Straube
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Straube @ 2018-11-26 18:12 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, linux, devel, linux-kernel

On 11/26/18 7:01 PM, Dan Carpenter wrote:
> On Mon, Nov 26, 2018 at 06:53:55PM +0100, Michael Straube wrote:

>>   	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
> 

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

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

end of thread, other threads:[~2018-11-26 21:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-26 17:53 [PATCH] staging: pi433: add missing call to cdev_del() Michael Straube
2018-11-26 18:01 ` Dan Carpenter
2018-11-26 18:12   ` Michael Straube

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.