From c829a48e198d723f0e6ae1ff6d6f820eb085711d Mon Sep 17 00:00:00 2001 From: aarya Date: Thu, 10 Mar 2022 09:16:44 +0530 Subject: serprog.c: Avoid calling memcpy with NULL pointer arguments In function sp_stream_buffer_op, the variable parms might be NULL when passed to memcpy. Although, since parmlen is also 0 at that time I don't think it would make much difference. Still, add a NULL check before calling memcpy to be safe. Change-Id: I850123237e328f9548ba7f77a01888be2cbc9e7b Signed-off-by: Aarya Chaumal Reviewed-on: https://review.coreboot.org/c/flashrom/+/62726 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan Reviewed-by: Anastasia Klimchuk Reviewed-by: Thomas Heijligen Reviewed-by: Nico Huber --- serprog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'serprog.c') diff --git a/serprog.c b/serprog.c index 2bbf44b3..ea2bbf0b 100644 --- a/serprog.c +++ b/serprog.c @@ -291,7 +291,8 @@ static int sp_stream_buffer_op(uint8_t cmd, uint32_t parmlen, uint8_t *parms) return 1; } sp[0] = cmd; - memcpy(&(sp[1]), parms, parmlen); + if (parms) + memcpy(&(sp[1]), parms, parmlen); if (sp_streamed_transmit_bytes >= (1 + parmlen + sp_device_serbuf_size)) { if (sp_flush_stream() != 0) { -- cgit v1.2.3