All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: christophe.jaillet@wanadoo.fr
Cc: linux-nvme@lists.infradead.org
Subject: [bug report] nvme-fc: improve memory usage in nvme_fc_rcv_ls_req()
Date: Fri, 2 Dec 2022 12:58:14 +0300	[thread overview]
Message-ID: <Y4nMNk+XvcAQDrmt@kili> (raw)

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


             reply	other threads:[~2022-12-02  9:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  9:58 Dan Carpenter [this message]
2022-12-02 14:11 ` [bug report] nvme-fc: improve memory usage in nvme_fc_rcv_ls_req() Chaitanya Kulkarni

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=Y4nMNk+XvcAQDrmt@kili \
    --to=error27@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --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.