mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 07:02:34 +02:00
libflashrom: Allow NULL-pointer argument in flashrom_flash_release()
free() allows NULL and it makes error paths easier to handle when one just needs to write `free(x);` without needing to care if `x` was allocated already. Let's follow this rule in flashrom_flash_release(). flashrom_layout_release() already checks for NULL. Change-Id: Id119c2e4f3aa1b11313059f11aac73c3e583185c Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/62340 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-by: Felix Singer <felixsinger@posteo.net>
This commit is contained in:
parent
60005a88ea
commit
8d50fad443
@ -361,6 +361,9 @@ size_t flashrom_flash_getsize(const struct flashrom_flashctx *const flashctx)
|
||||
*/
|
||||
void flashrom_flash_release(struct flashrom_flashctx *const flashctx)
|
||||
{
|
||||
if (!flashctx)
|
||||
return;
|
||||
|
||||
flashrom_layout_release(flashctx->default_layout);
|
||||
free(flashctx->chip);
|
||||
free(flashctx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user