Alexander Goncharov has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/81548?usp=email )
Change subject: erasure_layout: do not copy region buffers if they are null ......................................................................
erasure_layout: do not copy region buffers if they are null
memcpy() function expects 2nd parameter to be non-null. Make sure that the pointer is null before passing it to the function.
Found-by: scan-build, clang v17.0.6 Signed-off-by: Alexander Goncharov chat@joursoir.net Change-Id: I99aad4119f9c11bea75e3419926cc833bc1f68c5 --- M erasure_layout.c 1 file changed, 8 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/48/81548/1
diff --git a/erasure_layout.c b/erasure_layout.c index 1dd6b60..762cd64 100644 --- a/erasure_layout.c +++ b/erasure_layout.c @@ -381,11 +381,15 @@ }
_end: - memcpy(newcontents + region_start, old_start_buf, old_start - region_start); - memcpy(newcontents + old_end, old_end_buf, region_end - old_end); + if (old_start_buf) { + memcpy(newcontents + region_start, old_start_buf, old_start - region_start); + free(old_start_buf); + }
- free(old_start_buf); - free(old_end_buf); + if (old_end_buf) { + memcpy(newcontents + old_end, old_end_buf, region_end - old_end); + free(old_end_buf); + }
msg_cinfo("Erase/write done from %"PRIx32" to %"PRIx32"\n", region_start, region_end); return ret;