net/net: Fix possible dereference to of a NULL pointer
It is always possible that grub_zalloc() could fail, so we should check for a NULL return. Otherwise we run the risk of dereferencing a NULL pointer. Fixes: CID 296221 Signed-off-by: Darren Kenny <darren.kenny@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
8cb2848f96
commit
03f2515ae0
@ -86,8 +86,13 @@ grub_net_link_layer_add_address (struct grub_net_card *card,
|
||||
|
||||
/* Add sender to cache table. */
|
||||
if (card->link_layer_table == NULL)
|
||||
card->link_layer_table = grub_zalloc (LINK_LAYER_CACHE_SIZE
|
||||
* sizeof (card->link_layer_table[0]));
|
||||
{
|
||||
card->link_layer_table = grub_zalloc (LINK_LAYER_CACHE_SIZE
|
||||
* sizeof (card->link_layer_table[0]));
|
||||
if (card->link_layer_table == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
entry = &(card->link_layer_table[card->new_ll_entry]);
|
||||
entry->avail = 1;
|
||||
grub_memcpy (&entry->ll_address, ll, sizeof (entry->ll_address));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user