All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sridhar Markonda <sridharm@linux.ibm.com>
To: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com, phcoder@gmail.com,
	sudhakar@linux.ibm.com, stefanb@linux.ibm.com,
	nayna@linux.ibm.com, sridharm@linux.ibm.com,
	ssrish@linux.ibm.com
Subject: [PATCH v2] normal/menu_entry: Add grub_calloc failure check
Date: Tue,  2 Dec 2025 12:31:48 +0530	[thread overview]
Message-ID: <20251202070148.35202-1-sridharm@linux.ibm.com> (raw)

Add a NULL check to prevent failure from grub_calloc in update_screen.
This stops possible NULL pointer dereference and avoids unexpected behavior.

Signed-off-by: Sridhar Markonda <sridharm@linux.ibm.com>
---
 grub-core/normal/menu_entry.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
index 8b0d17e3f..411b0ad53 100644
--- a/grub-core/normal/menu_entry.c
+++ b/grub-core/normal/menu_entry.c
@@ -295,8 +295,12 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
 
 	  pos = linep->pos + (term_screen - screen->terms);
 
-	  if (!*pos)
-	    *pos = grub_calloc (linep->len + 1, sizeof (**pos));
+	  if (*pos == NULL)
+	    {
+	      *pos = grub_calloc (linep->len + 1, sizeof (**pos));
+	      if (*pos == NULL)
+		return;
+	    }
 
 	  if (i == region_start || linep == screen->lines + screen->line
 	      || (i > region_start && mode == ALL_LINES))
-- 
2.47.3


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2025-12-02  7:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02  7:01 Sridhar Markonda [this message]
     [not found] <mailman.4226.1764658927.1191.grub-devel@gnu.org>
2025-12-02 17:33 ` [PATCH v2] normal/menu_entry: Add grub_calloc failure check Avnish Chouhan
2025-12-20 13:14   ` Daniel Kiper

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=20251202070148.35202-1-sridharm@linux.ibm.com \
    --to=sridharm@linux.ibm.com \
    --cc=daniel.kiper@oracle.com \
    --cc=grub-devel@gnu.org \
    --cc=nayna@linux.ibm.com \
    --cc=phcoder@gmail.com \
    --cc=ssrish@linux.ibm.com \
    --cc=stefanb@linux.ibm.com \
    --cc=sudhakar@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.