From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Alexander.Barabash@dell.com" <Alexander.Barabash@dell.com>,
Alexander Barabash <alexander.barabash@dell.com>,
Dave Jiang <dave.jiang@intel.com>, Vinod Koul <vkoul@kernel.org>,
Sasha Levin <sashal@kernel.org>,
dmaengine@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 5/8] ioat: ioat_alloc_ring() failure handling.
Date: Fri, 10 Jan 2020 17:06:18 -0500 [thread overview]
Message-ID: <20200110220621.28651-5-sashal@kernel.org> (raw)
In-Reply-To: <20200110220621.28651-1-sashal@kernel.org>
From: "Alexander.Barabash@dell.com" <Alexander.Barabash@dell.com>
[ Upstream commit b0b5ce1010ffc50015eaec72b0028aaae3f526bb ]
If dma_alloc_coherent() returns NULL in ioat_alloc_ring(), ring
allocation must not proceed.
Until now, if the first call to dma_alloc_coherent() in
ioat_alloc_ring() returned NULL, the processing could proceed, failing
with NULL-pointer dereferencing further down the line.
Signed-off-by: Alexander Barabash <alexander.barabash@dell.com>
Acked-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/75e9c0e84c3345d693c606c64f8b9ab5@x13pwhopdag1307.AMER.DELL.COM
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/dma/ioat/dma.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index f70cc74032ea..e3899ae429e0 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -388,10 +388,11 @@ ioat_alloc_ring(struct dma_chan *c, int order, gfp_t flags)
descs->virt = dma_alloc_coherent(to_dev(ioat_chan),
SZ_2M, &descs->hw, flags);
- if (!descs->virt && (i > 0)) {
+ if (!descs->virt) {
int idx;
for (idx = 0; idx < i; idx++) {
+ descs = &ioat_chan->descs[idx];
dma_free_coherent(to_dev(ioat_chan), SZ_2M,
descs->virt, descs->hw);
descs->virt = NULL;
--
2.20.1
next prev parent reply other threads:[~2020-01-10 22:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 22:06 [PATCH AUTOSEL 4.14 1/8] mips: cacheinfo: report shared CPU map Sasha Levin
2020-01-10 22:06 ` [PATCH AUTOSEL 4.14 2/8] MIPS: Prevent link failure with kcov instrumentation Sasha Levin
2020-01-10 22:06 ` [PATCH AUTOSEL 4.14 3/8] dmaengine: k3dma: Avoid null pointer traversal Sasha Levin
2020-01-10 22:06 ` [PATCH AUTOSEL 4.14 4/8] hsr: reset network header when supervision frame is created Sasha Levin
2020-01-10 22:06 ` Sasha Levin [this message]
2020-01-10 22:06 ` [PATCH AUTOSEL 4.14 6/8] hexagon: parenthesize registers in asm predicates Sasha Levin
2020-01-10 22:06 ` [PATCH AUTOSEL 4.14 7/8] hexagon: work around compiler crash Sasha Levin
2020-01-10 22:06 ` [PATCH AUTOSEL 4.14 8/8] ocfs2: call journal flush to mark journal as empty after journal recovery when mount Sasha Levin
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=20200110220621.28651-5-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Alexander.Barabash@dell.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=vkoul@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox