From: "yiyang (D)" <yiyang13@huawei.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: <davem@davemloft.net>, <jirislaby@kernel.org>,
<jag.raman@oracle.com>, <linux-serial@vger.kernel.org>
Subject: Re: [PATCH] tty: vcc: Add check for kstrdup() in vcc_probe()
Date: Mon, 4 Sep 2023 11:45:11 +0800 [thread overview]
Message-ID: <b73d22ba-8f19-286e-9441-ac456bf37be5@huawei.com> (raw)
In-Reply-To: <2023090321-conch-stopper-51c7@gregkh>
On 2023/9/3 18:49, Greg KH wrote:
> On Sun, Sep 03, 2023 at 06:13:22PM +0800, Yi Yang wrote:
>> Add check for the return value of kstrdup() and return the error, if it
>> fails in order to avoid NULL pointer dereference.
>>
>> Fixes: 5d171050e28f ("sparc64: vcc: Enable VCC port probe and removal")
>> Signed-off-by: Yi Yang <yiyang13@huawei.com>
>> ---
>> drivers/tty/vcc.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c
>> index a39ed981bfd3..420d334f6077 100644
>> --- a/drivers/tty/vcc.c
>> +++ b/drivers/tty/vcc.c
>> @@ -579,6 +579,10 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
>> return -ENOMEM;
>>
>> name = kstrdup(dev_name(&vdev->dev), GFP_KERNEL);
>> + if (!name) {
>> + kfree(port);
>> + return -ENOMEM;
>
> Please just add another goto target later in the function like the rest
> of the error paths follow.
Ok, i will send v2 patch for this issue.
>
> And how did you test this patch?
>
I use crosstool-ng build sparc arch for open CONFIG_VCC.
> thanks,
>
> greg k-h
> .
>
--
thanks for your advice.
Yi Yang
next prev parent reply other threads:[~2023-09-04 3:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-03 10:13 [PATCH] tty: vcc: Add check for kstrdup() in vcc_probe() Yi Yang
2023-09-03 10:49 ` Greg KH
2023-09-04 3:45 ` yiyang (D) [this message]
2023-09-04 6:17 ` Greg KH
2023-09-04 6:40 ` yiyang (D)
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=b73d22ba-8f19-286e-9441-ac456bf37be5@huawei.com \
--to=yiyang13@huawei.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=jag.raman@oracle.com \
--cc=jirislaby@kernel.org \
--cc=linux-serial@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox