Skip to content

Commit

Permalink
intel_th: msu-sink: Potential dereference of null pointer
Browse files Browse the repository at this point in the history
[ Upstream commit 82f76a4 ]

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: f220df6 ("intel_th: msu-sink: An example msu buffer "sink"")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Link: https://lore.kernel.org/r/20220705082637.59979-3-alexander.shishkin@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Jiasheng Jiang authored and Greg Kroah-Hartman committed Aug 21, 2022
1 parent a8f3b78 commit 81222cf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/hwtracing/intel_th/msu-sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 81222cf

Please sign in to comment.