mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 3/4] efi: payload: gracefully handle NULL parent image device path
Date: Tue, 11 Jun 2024 08:57:17 +0200	[thread overview]
Message-ID: <20240611065718.2899625-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240611065718.2899625-1-a.fatoum@pengutronix.de>

device_path_to_filepath may be called on a device pth that contains no
file path. In that case, the function should return NULL instead of
dereferencing the NULL pointer. Fix this.

Fixes: f1230c7f92cd ("efi: payload: dynamically determine bootloader file name")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 efi/devicepath.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/efi/devicepath.c b/efi/devicepath.c
index 23963aa0cbb7..ecb3e7b64cc1 100644
--- a/efi/devicepath.c
+++ b/efi/devicepath.c
@@ -824,6 +824,9 @@ char *device_path_to_filepath(const struct efi_device_path *dev_path)
 		dev_path = next_device_path_node(&fp->header);
 	}
 
+	if (!fp)
+		return NULL;
+
 	path = strdup_wchar_to_char(fp->path_name);
 	if (!path)
 		return NULL;
-- 
2.39.2




  parent reply	other threads:[~2024-06-11  6:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11  6:57 [PATCH master 1/4] efi: hide EFI related symbols when !EFI Ahmad Fatoum
2024-06-11  6:57 ` [PATCH master 2/4] lib: wchar: guard against NULL in strdup_wchar Ahmad Fatoum
2024-06-11  6:57 ` Ahmad Fatoum [this message]
2024-06-11  6:57 ` [PATCH master 4/4] fs: legacy: gracefully handle non existent files Ahmad Fatoum
2024-06-13  7:30 ` [PATCH master 1/4] efi: hide EFI related symbols when !EFI Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240611065718.2899625-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox