From: Johan Hovold <johan@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Denis Joseph Barrow <D.Barow@option.com>,
Jakub Kicinski <kuba@kernel.org>,
Oliver Neukum <oneukum@suse.com>,
Anirudh Rayabharam <mail@anirudhrb.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rustam Kovhaev <rkovhaev@gmail.com>,
Zheng Yongjun <zhengyongjun3@huawei.com>,
Emil Renner Berthing <kernel@esmil.dk>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net] net: hso: check for allocation failure in hso_create_bulk_serial_device()
Date: Wed, 12 May 2021 12:19:03 +0200 [thread overview]
Message-ID: <YJurlxqQ9L+zzIAS@hovoldconsulting.com> (raw)
In-Reply-To: <YJupQPb+Y4vw3rDk@mwanda>
On Wed, May 12, 2021 at 01:09:04PM +0300, Dan Carpenter wrote:
> Add a couple checks for if these allocations fail.
>
> Fixes: 542f54823614 ("tty: Modem functions for the HSO driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/net/usb/hso.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
> index 3ef4b2841402..3b2a868d7a72 100644
> --- a/drivers/net/usb/hso.c
> +++ b/drivers/net/usb/hso.c
> @@ -2618,9 +2618,13 @@ static struct hso_device *hso_create_bulk_serial_device(
> num_urbs = 2;
> serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget),
> GFP_KERNEL);
> + if (!serial->tiocmget)
> + goto exit;
Nice catch; the next assignment would go boom if this ever failed.
This appears to have been introduced by
af0de1303c4e ("usb: hso: obey DMA rules in tiocmget")
> serial->tiocmget->serial_state_notification
> = kzalloc(sizeof(struct hso_serial_state_notification),
> GFP_KERNEL);
> + if (!serial->tiocmget->serial_state_notification)
> + goto exit;
> /* it isn't going to break our heart if serial->tiocmget
> * allocation fails don't bother checking this.
> */
You should remove this comment and drop the conditional on the following
line as well now, though.
Johan
next prev parent reply other threads:[~2021-05-12 10:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 10:09 [PATCH net] net: hso: check for allocation failure in hso_create_bulk_serial_device() Dan Carpenter
2021-05-12 10:19 ` Johan Hovold [this message]
2021-05-12 13:12 ` Dan Carpenter
2021-05-14 14:24 ` [PATCH v2 " Dan Carpenter
2021-05-17 8:07 ` Johan Hovold
2021-05-17 21:00 ` patchwork-bot+netdevbpf
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=YJurlxqQ9L+zzIAS@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=D.Barow@option.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kernel@esmil.dk \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mail@anirudhrb.com \
--cc=netdev@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=rkovhaev@gmail.com \
--cc=zhengyongjun3@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 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).