[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211217020047.446983-1-jiasheng@iscas.ac.cn>
Date: Fri, 17 Dec 2021 10:00:47 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: alexander.shishkin@...ux.intel.com
Cc: linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] intel_th: msu-sink: potential dereference of null pointer
The return value of dma_alloc_coherent() needs to be checked.
To avoid use of null pointer in sg_set_buf() in case of the failure of
alloc.
Fixes: f220df66f676 ("intel_th: msu-sink: An example msu buffer "sink"")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
drivers/hwtracing/intel_th/msu-sink.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/hwtracing/intel_th/msu-sink.c b/drivers/hwtracing/intel_th/msu-sink.c
index 2c7f5116be12..891b28ea25fe 100644
--- a/drivers/hwtracing/intel_th/msu-sink.c
+++ b/drivers/hwtracing/intel_th/msu-sink.c
@@ -71,6 +71,9 @@ static int msu_sink_alloc_window(void *data, struct sg_table **sgt, size_t size)
block = dma_alloc_coherent(priv->dev->parent->parent,
PAGE_SIZE, &sg_dma_address(sg_ptr),
GFP_KERNEL);
+ if (!block)
+ return -ENOMEM;
+
sg_set_buf(sg_ptr, block, PAGE_SIZE);
}
--
2.25.1
Powered by blists - more mailing lists