From: Jiasheng Jiang Date: Tue, 5 Jul 2022 08:26:33 +0000 (+0300) Subject: intel_th: msu-sink: Potential dereference of null pointer X-Git-Tag: baikal/mips/sdk6.1~5150^2~48 X-Git-Url: https://git.baikalelectronics.ru/?a=commitdiff_plain;h=4f30d95db3de62262dbd6f1e4d6f7d12a14aa1ee;p=kernel.git 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: c5e79f497312 ("intel_th: msu-sink: An example msu buffer "sink"") Reviewed-by: Andy Shevchenko Signed-off-by: Jiasheng Jiang Signed-off-by: Alexander Shishkin Link: https://lore.kernel.org/r/20220705082637.59979-3-alexander.shishkin@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hwtracing/intel_th/msu-sink.c b/drivers/hwtracing/intel_th/msu-sink.c index 2c7f5116be126..891b28ea25fe6 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); }