mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-24 08:09:22 +00:00
kern/command,commands/extcmd: Perform explicit NULL check in both the unregister helpers
During command registration, grub_register_command_prio() returns
a 0 when there is a failure in memory allocation. In such a situation,
calls to grub_unregister_{command(), extcmd()} during command
unregistration will result in dereferencing a NULL pointer.
Perform explicit NULL check in both unregister helpers to prevent
undefined behaviour due to a NULL pointer dereference.
Signed-off-by: Srish Srinivasan <ssrish@linux.ibm.com>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
9a725391f1
commit
fa93f2412b
2 files changed
+6
No files matched your search
@@ -139,6 +139,9 @@ grub_register_extcmd_lockdown (const char *name, grub_extcmd_func_t func,
|
||||
void
|
||||
grub_unregister_extcmd (grub_extcmd_t ext)
|
||||
{
|
||||
if (ext == NULL)
|
||||
return;
|
||||
|
||||
grub_unregister_command (ext->cmd);
|
||||
grub_free (ext);
|
||||
}
|
||||
@@ -104,6 +104,9 @@ grub_register_command_lockdown (const char *name,
|
||||
void
|
||||
grub_unregister_command (grub_command_t cmd)
|
||||
{
|
||||
if (cmd == NULL)
|
||||
return;
|
||||
|
||||
if ((cmd->prio & GRUB_COMMAND_FLAG_ACTIVE) && (cmd->next))
|
||||
cmd->next->prio |= GRUB_COMMAND_FLAG_ACTIVE;
|
||||
grub_list_remove (GRUB_AS_LIST (cmd));
|
||||
|
||||
Reference in new issue
Block a user