Skip to contentSkip to conversation

efi: fix memory leak in error path

PATCH Applied Lucas Stach 2 participants 6 messages Mar 2, 2016 – Mar 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 efi: fix memory leak in error path

---
 arch/efi/efi/efi-device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/efi/efi/efi-device.c +3 -1
index 7db8e48..678a283 100644
@@ -168,8 +168,10 @@ static struct efi_device *efi_add_device(efi_handle_t *handle, efi_guid_t **guid
 
 	efiret = BS->open_protocol(handle, &efi_device_path_protocol_guid,
 			&devpath, NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
-	if (EFI_ERROR(efiret))
+	if (EFI_ERROR(efiret)) {
+		free(guidarr);
 		return ERR_PTR(-EINVAL);
+	}
 
 	efidev = xzalloc(sizeof(*efidev));
 
Signature · 7 lines
2.5.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/5 net: efi: correct function signature of set_ethaddr

---
 drivers/net/efi-snp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/efi-snp.c +1 -1
index 5b96fbf..963d539 100644
@@ -238,7 +238,7 @@ static int efi_snp_get_ethaddr(struct eth_device *edev, unsigned char *adr)
 	return 0;
 }
 
-static int efi_snp_set_ethaddr(struct eth_device *edev, unsigned char *adr)
+static int efi_snp_set_ethaddr(struct eth_device *edev, const unsigned char *adr)
 {
 	return 0;
 }
Signature · 7 lines
2.5.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/5 fs: efi: avoid comparison with uninitialized variable

In reply to Lucas Stach

volume will only be initialized when efi_loaded_image is set.

---
 fs/efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/efi.c +1 -1
index a7adcb9..0f74cda 100644
@@ -527,7 +527,7 @@ int efi_fs_probe(struct efi_device *efidev)
 		BS->handle_protocol(efi_loaded_image->device_handle,
 				&efi_simple_file_system_protocol_guid, (void*)&volume);
 
-	if (efidev->protocol == volume)
+	if (efi_loaded_image && efidev->protocol == volume)
 		path = xstrdup("/boot");
 	else
 		path = asprintf("/efi%d", index);
Signature · 7 lines
2.5.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 4/5 bbu: use correct printf format specifier for size_t

In reply to Lucas Stach
---
 common/bbu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/bbu.c +1 -1
index 4d71fa4..fc82193 100644
@@ -187,7 +187,7 @@ static int bbu_std_file_handler(struct bbu_handler *handler,
 		oflags |= O_CREAT;
 	} else {
 		if (!S_ISREG(s.st_mode) && s.st_size < data->len) {
-			printf("Image (%lld) is too big for device (%d)\n",
+			printf("Image (%lld) is too big for device (%zd)\n",
 					s.st_size, data->len);
 		}
 	}
Signature · 7 lines
2.5.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 5/5 ratp: use proper defines for BAREBOX_CMD

In reply to Lucas Stach
---
 common/ratp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/ratp.c +1 -1
index 2fef3cc..edd20dc 100644
@@ -410,7 +410,7 @@ static int do_ratp_close(int argc, char *argv[])
 
 BAREBOX_CMD_START(ratp_close)
 	.cmd	= do_ratp_close,
-};
+BAREBOX_CMD_END
 
 int barebox_ratp_fs_call(struct ratp_bb_pkt *tx, struct ratp_bb_pkt **rx)
 {
Signature · 7 lines
2.5.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#5 lore raw
In reply to Lucas Stach
Quoted 4 lines · Lucas Stach
---
 arch/efi/efi/efi-device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied all to master, thanks

Sascha

Quoted 26 lines
arch/efi/efi/efi-device.c +3 -1
index 7db8e48..678a283 100644
@@ -168,8 +168,10 @@ static struct efi_device *efi_add_device(efi_handle_t *handle, efi_guid_t **guid
 
 	efiret = BS->open_protocol(handle, &efi_device_path_protocol_guid,
 			&devpath, NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
-	if (EFI_ERROR(efiret))
+	if (EFI_ERROR(efiret)) {
+		free(guidarr);
 		return ERR_PTR(-EINVAL);
+	}
 
 	efidev = xzalloc(sizeof(*efidev));
 
Signature · 7 lines
2.5.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox