Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH] nvme-pci: move use_sgl initialization to nvme_init_iod()
Date: Tue, 19 Dec 2017 13:45:30 -0700	[thread overview]
Message-ID: <20171219204530.GB23384@localhost.localdomain> (raw)
In-Reply-To: <1513525642-23481-1-git-send-email-minwoo.im.dev@gmail.com>

On Mon, Dec 18, 2017@12:47:22AM +0900, Minwoo Im wrote:
> A flag "use_sgl" of "struct nvme_iod" has been used in nvme_init_iod()
> without being set to any value. It seems like "use_sgl" has been set
> in either nvme_pci_setup_prps() or nvme_pci_setup_sgls() which occur
> later than nvme_init_iod().
> 
> Make "iod->use_sgl" being set in a proper place, nvme_init_iod().
> Also move nvme_pci_use_sgls() up above nvme_init_iod() to make it
> possible to be called by nvme_init_iod().
> 
> Signed-off-by: Minwoo Im <minwoo.im.dev at gmail.com>

Nice catch. We're potentially corrupting memory without this fix since
the allocation size depends on whether or not SGLs are used, so we may
be under allocating what's actually used today!

> @@ -455,14 +472,17 @@ static blk_status_t nvme_init_iod(struct request *rq, struct nvme_dev *dev)
>  	unsigned int size = blk_rq_payload_bytes(rq);
>  
>  	if (nseg > NVME_INT_PAGES || size > NVME_INT_BYTES(dev)) {
> +		bool use_sgl = nvme_pci_use_sgls(dev, rq);

No need for the temporary vairable here, just set iod->use_sgl directly.

  reply	other threads:[~2017-12-19 20:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-17 15:47 [PATCH] nvme-pci: move use_sgl initialization to nvme_init_iod() Minwoo Im
2017-12-19 20:45 ` Keith Busch [this message]
2017-12-20  7:20   ` Minwoo Im

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=20171219204530.GB23384@localhost.localdomain \
    --to=keith.busch@intel.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