linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] chardev: fix error handling in cdev_device_add()
@ 2021-10-12 13:09 Yang Yingliang
  2021-12-23  1:41 ` Yang Yingliang
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Yingliang @ 2021-10-12 13:09 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel; +Cc: viro

If dev->devt is not set, cdev_device_add() will not add the cdev,
when device_add failed, cdev_del() is not needed, so delete cdev
only when dev->devt is set.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 233ed09d7fda ("chardev: add helper function to register...")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 fs/char_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/char_dev.c b/fs/char_dev.c
index ba0ded7842a7..3f667292608c 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -547,7 +547,7 @@ int cdev_device_add(struct cdev *cdev, struct device *dev)
 	}
 
 	rc = device_add(dev);
-	if (rc)
+	if (rc && dev->devt)
 		cdev_del(cdev);
 
 	return rc;
-- 
2.25.1


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

* Re: [PATCH] chardev: fix error handling in cdev_device_add()
  2021-10-12 13:09 [PATCH] chardev: fix error handling in cdev_device_add() Yang Yingliang
@ 2021-12-23  1:41 ` Yang Yingliang
  2021-12-23  7:15   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Yingliang @ 2021-12-23  1:41 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel
  Cc: viro, logang, dan.j.williams, hans.verkuil, alexandre.belloni, Greg KH

ping...

On 2021/10/12 21:09, Yang Yingliang wrote:
> If dev->devt is not set, cdev_device_add() will not add the cdev,
> when device_add failed, cdev_del() is not needed, so delete cdev
> only when dev->devt is set.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes: 233ed09d7fda ("chardev: add helper function to register...")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>   fs/char_dev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/char_dev.c b/fs/char_dev.c
> index ba0ded7842a7..3f667292608c 100644
> --- a/fs/char_dev.c
> +++ b/fs/char_dev.c
> @@ -547,7 +547,7 @@ int cdev_device_add(struct cdev *cdev, struct device *dev)
>   	}
>   
>   	rc = device_add(dev);
> -	if (rc)
> +	if (rc && dev->devt)
>   		cdev_del(cdev);
>   
>   	return rc;

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

* Re: [PATCH] chardev: fix error handling in cdev_device_add()
  2021-12-23  1:41 ` Yang Yingliang
@ 2021-12-23  7:15   ` Greg KH
  2021-12-23  7:43     ` Yang Yingliang
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-12-23  7:15 UTC (permalink / raw)
  To: Yang Yingliang
  Cc: linux-kernel, linux-fsdevel, viro, logang, dan.j.williams,
	hans.verkuil, alexandre.belloni

On Thu, Dec 23, 2021 at 09:41:03AM +0800, Yang Yingliang wrote:
> ping...

ping of what?  You suddenly added a bunch of people that were not on the
original thread here with no context :(

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

* Re: [PATCH] chardev: fix error handling in cdev_device_add()
  2021-12-23  7:15   ` Greg KH
@ 2021-12-23  7:43     ` Yang Yingliang
  0 siblings, 0 replies; 4+ messages in thread
From: Yang Yingliang @ 2021-12-23  7:43 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel, linux-fsdevel, viro, logang, dan.j.williams,
	hans.verkuil, alexandre.belloni

Hi,

On 2021/12/23 15:15, Greg KH wrote:
> On Thu, Dec 23, 2021 at 09:41:03AM +0800, Yang Yingliang wrote:
>> ping...
> ping of what?  You suddenly added a bunch of people that were not on the
> original thread here with no context :(
> .
This patch has been in mail list for a while time, I add the author and 
reviewer of fixed patch
to this thread,  I would like to get some advice. Should I resend the 
patch with cc those people ?

Thanks,
Yang

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

end of thread, other threads:[~2021-12-23  7:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 13:09 [PATCH] chardev: fix error handling in cdev_device_add() Yang Yingliang
2021-12-23  1:41 ` Yang Yingliang
2021-12-23  7:15   ` Greg KH
2021-12-23  7:43     ` Yang Yingliang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).