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().

Change-Id: Id119c2e4f3aa1b11313059f11aac73c3e583185c
Signed-off-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/62340
Original-Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Original-Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71446
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/libflashrom.c b/libflashrom.c
index c336b8c..fd3648f 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -237,6 +237,9 @@
  */
 void flashrom_flash_release(struct flashrom_flashctx *const flashctx)
 {
+	if (!flashctx)
+		return;
+
 	free(flashctx->chip);
 	free(flashctx);
 }