From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Dan Carpenter <error27@gmail.com>
Cc: "christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: Re: [bug report] nvme-fc: improve memory usage in nvme_fc_rcv_ls_req()
Date: Fri, 2 Dec 2022 14:11:50 +0000 [thread overview]
Message-ID: <4E98047B-FA41-4A56-BF51-203D06CF5B87@nvidia.com> (raw)
In-Reply-To: <Y4nMNk+XvcAQDrmt@kili>
> On Dec 2, 2022, at 1:59 AM, Dan Carpenter <error27@gmail.com> wrote:
>
> Hello Christophe JAILLET,
>
> The patch cf3d00840170: "nvme-fc: improve memory usage in
> nvme_fc_rcv_ls_req()" from Oct 2, 2022, leads to the following Smatch
> static checker warning:
>
> drivers/nvme/host/fc.c:1757 nvme_fc_rcv_ls_req() error: potential null dereference 'lsop'. (kzalloc returns null)
> drivers/nvme/host/fc.c:1759 nvme_fc_rcv_ls_req() warn: variable dereferenced before check 'lsop' (see line 1757)
>
> drivers/nvme/host/fc.c
> 1747 if (lsreqbuf_len > sizeof(union nvmefc_ls_requests)) {
> 1748 dev_info(lport->dev,
> 1749 "RCV %s LS failed: payload too large\n",
> 1750 (w0->ls_cmd <= NVME_FC_LAST_LS_CMD_VALUE) ?
> 1751 nvmefc_ls_names[w0->ls_cmd] : "");
> 1752 ret = -E2BIG;
> 1753 goto out_put;
> 1754 }
> 1755
> 1756 lsop = kzalloc(sizeof(*lsop), GFP_KERNEL);
> --> 1757 lsop->rqstbuf = kzalloc(sizeof(*lsop->rqstbuf), GFP_KERNEL);
> ^^^^^^^^^^^^^
>
> 1758 lsop->rspbuf = kzalloc(sizeof(*lsop->rspbuf), GFP_KERNEL);
> 1759 if (!lsop || !lsop->rqstbuf || !lsop->rspbuf) {
> ^^^^
>
> 1760 dev_info(lport->dev,
> 1761 "RCV %s LS failed: No memory\n",
> 1762 (w0->ls_cmd <= NVME_FC_LAST_LS_CMD_VALUE) ?
> 1763 nvmefc_ls_names[w0->ls_cmd] : "");
> 1764 ret = -ENOMEM;
> 1765 goto out_free;
> 1766 }
> 1767
>
> regards,
> dan carpenter
>
I already sent out a fix on NVMe mailing list ...
-ck
prev parent reply other threads:[~2022-12-02 14:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 9:58 [bug report] nvme-fc: improve memory usage in nvme_fc_rcv_ls_req() Dan Carpenter
2022-12-02 14:11 ` Chaitanya Kulkarni [this message]
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=4E98047B-FA41-4A56-BF51-203D06CF5B87@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=error27@gmail.com \
--cc=linux-nvme@lists.infradead.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 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.