term/ieee1275/serial: Fix memory leak
The grub_zalloc() allocates memory for port. If the allocation for port->name fails the function returns NULL without freeing the previously allocated port memory. This results in a memory leak. To avoid this we must free port before return. Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com> Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
cc36d0f088
commit
5f0ffd7f57
@ -236,7 +236,11 @@ add_port (struct ofserial_hash_ent *ent)
|
||||
+ grub_strlen (ent->shortest));
|
||||
port->elem = ent;
|
||||
if (!port->name)
|
||||
return NULL;
|
||||
{
|
||||
grub_free (port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr = grub_stpcpy (port->name, "ieee1275/");
|
||||
grub_strcpy (ptr, ent->shortest);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user