From: Greg KH <gregkh@linuxfoundation.org>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
logang@deltatee.com, dan.j.williams@intel.com,
hans.verkuil@cisco.com, alexandre.belloni@free-electrons.com,
viro@zeniv.linux.org.uk
Subject: Re: [PATCH RESEND] chardev: fix error handling in cdev_device_add()
Date: Thu, 14 Jul 2022 11:33:16 +0200 [thread overview]
Message-ID: <Ys/i3EBk2nZea8Hy@kroah.com> (raw)
In-Reply-To: <20220714092355.991306-1-yangyingliang@huawei.com>
On Thu, Jul 14, 2022 at 05:23:55PM +0800, Yang Yingliang wrote:
> If dev->devt is not set, cdev_add() will not be called, so if device_add()
> fails, cdev_del() is not needed. Fix this by checking dev->devt in error
> case.
>
> Fixes: 233ed09d7fda ("chardev: add helper function to register char devs with a struct device")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> 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
>
Please see https://lore.kernel.org/r/YsLtXYa4kRYEEaX/@kroah.com for why
I will no longer accept patches from Huawei with the "hulk robot" claim
without the required information.
Also, you did not state why this was a RESEND.
Now dropped from my review queue,
greg k-h
next prev parent reply other threads:[~2022-07-14 9:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-14 9:23 [PATCH RESEND] chardev: fix error handling in cdev_device_add() Yang Yingliang
2022-07-14 9:33 ` Greg KH [this message]
2022-08-01 2:05 ` Yang Yingliang
2022-08-01 6:20 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2022-12-02 3:02 [PATCH resend] " Yang Yingliang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ys/i3EBk2nZea8Hy@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=alexandre.belloni@free-electrons.com \
--cc=dan.j.williams@intel.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=viro@zeniv.linux.org.uk \
--cc=yangyingliang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.