From: Jack Wang <jinpu.wang@ionos.com>
To: linux-kernel@vger.kernel.org
Cc: James Smart <james.smart@broadcom.com>,
Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@fb.com>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org
Subject: [PATCH v1 15/19] nvme-fc: Fix the error check for dma_map_sg
Date: Fri, 19 Aug 2022 08:07:57 +0200 [thread overview]
Message-ID: <20220819060801.10443-16-jinpu.wang@ionos.com> (raw)
In-Reply-To: <20220819060801.10443-1-jinpu.wang@ionos.com>
dma_map_sg return 0 on error, add missing check.
Cc: James Smart <james.smart@broadcom.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
---
drivers/nvme/host/fc.c | 2 +-
drivers/nvme/target/fc.c | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 127abaf9ba5d..95050f2e0a06 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2616,7 +2616,7 @@ nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq,
WARN_ON(op->nents > blk_rq_nr_phys_segments(rq));
freq->sg_cnt = fc_dma_map_sg(ctrl->lport->dev, freq->sg_table.sgl,
op->nents, rq_dma_dir(rq));
- if (unlikely(freq->sg_cnt <= 0)) {
+ if (unlikely(!freq->sg_cnt)) {
sg_free_table_chained(&freq->sg_table, NVME_INLINE_SG_CNT);
freq->sg_cnt = 0;
return -EFAULT;
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index ab2627e17bb9..3749ca28860b 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -2089,6 +2089,11 @@ nvmet_fc_alloc_tgt_pgs(struct nvmet_fc_fcp_iod *fod)
((fod->io_dir == NVMET_FCP_WRITE) ?
DMA_FROM_DEVICE : DMA_TO_DEVICE));
/* note: write from initiator perspective */
+ if (!fod->data_sg_cnt) {
+ sgl_free(fod->data_sg);
+ fod->data_sg = NULL;
+ goto out;
+ }
fod->next_sg = fod->data_sg;
return 0;
--
2.34.1
next prev parent reply other threads:[~2022-08-19 6:09 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-19 6:07 [PATCH v1 00/19] Fix dma_map_sg error check Jack Wang
2022-08-19 6:07 ` [PATCH v1 01/19] mailbox: bcm-ferxrm-mailbox: Fix error check for dma_map_sg Jack Wang
2022-08-22 5:07 ` Dan Carpenter
2022-08-22 9:58 ` Jinpu Wang
2022-08-19 6:07 ` [PATCH v1 02/19] infiniband/mthca: Fix dma_map_sg error check Jack Wang
2022-08-19 22:19 ` Kees Cook
2022-08-21 11:46 ` Leon Romanovsky
2022-08-22 5:11 ` Dan Carpenter
2022-08-19 6:07 ` [PATCH v1 03/19] HSI: omap_ssi_port: " Jack Wang
2022-08-19 6:07 ` [PATCH v1 04/19] mtd: rawnand: stm32_fmc2: " Jack Wang
2022-08-23 7:49 ` Christophe Kerello
2022-09-20 8:34 ` Miquel Raynal
2022-08-19 6:07 ` [PATCH v1 05/19] mtd: rawnand: marvell: Fix error handle regarding dma_map_sg Jack Wang
2022-09-20 8:34 ` Miquel Raynal
2022-08-19 6:07 ` [PATCH v1 06/19] usb/hcd: Fix dma_map_sg error check Jack Wang
2022-08-19 6:07 ` [PATCH v1 07/19] crypto: gemin: Fix error check for dma_map_sg Jack Wang
2022-08-26 8:13 ` Linus Walleij
2022-08-26 11:06 ` Herbert Xu
2022-08-26 12:04 ` LABBE Corentin
2022-08-26 12:08 ` Jinpu Wang
2022-08-19 6:07 ` [PATCH v1 08/19] crypto: sahara: " Jack Wang
2022-08-19 6:07 ` [PATCH v1 09/19] crypto: qce: Fix dma_map_sg error check Jack Wang
2022-08-19 6:07 ` [PATCH v1 10/19] crypto: amlogic: " Jack Wang
2022-08-26 12:46 ` LABBE Corentin
2022-08-19 6:07 ` [PATCH v1 11/19] crypto: allwinner: " Jack Wang
2022-08-19 6:07 ` [PATCH v1 12/19] crypto: ccree: " Jack Wang
2022-08-21 9:44 ` Gilad Ben-Yossef
2022-08-19 6:07 ` [PATCH v1 13/19] intel_th: " Jack Wang
2022-08-19 6:07 ` [PATCH v1 14/19] nvme-rdma: Fix error check for ib_dma_map_sg Jack Wang
2022-08-21 5:57 ` Christoph Hellwig
2022-08-22 5:12 ` Jinpu Wang
2022-08-22 6:25 ` Christoph Hellwig
2022-08-22 7:10 ` Jinpu Wang
2022-08-19 6:07 ` Jack Wang [this message]
2022-08-19 6:07 ` [PATCH v1 16/19] scsi/qlogicpti: Fix dma_map_sg check Jack Wang
2022-08-19 6:07 ` [PATCH v1 17/19] mmc: meson-mx-sdhc: Fix error check for dma_map_sg Jack Wang
2022-08-20 17:25 ` Martin Blumenstingl
2022-08-22 5:15 ` Jinpu Wang
2022-08-19 6:08 ` [PATCH v1 18/19] mmc: jz4740_mmc: " Jack Wang
2022-08-19 6:08 ` [PATCH v1 19/19] net/mlx4: " Jack Wang
2022-08-21 11:42 ` Leon Romanovsky
2022-08-22 18:20 ` Jakub Kicinski
2022-08-24 14:39 ` Jinpu Wang
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=20220819060801.10443-16-jinpu.wang@ionos.com \
--to=jinpu.wang@ionos.com \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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
all inboxes | Powered by JetHome®