All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] staging: gasket Create a memory allocation path
@ 2018-10-31 16:47 Ioannis Valasakis
  2018-10-31 16:54 ` [Outreachy kernel] " Sasha Levin
  2018-10-31 20:40 ` Julia Lawall
  0 siblings, 2 replies; 8+ messages in thread
From: Ioannis Valasakis @ 2018-10-31 16:47 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: gregkh, alexander.levin

Fix multiple error allocation path by using re-direction.

Signed-off-by: Ioannis Valasakis <code@wizofe.uk>
---
Changes in v2:
	- Specific tags for memory allocation
	- Free the memory in the right way as for kfre

drivers/staging/gasket/gasket_interrupt.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c
index cdfb72af1c52..23232ea8f4d9 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -348,21 +348,21 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name,
 					       sizeof(struct msix_entry),
 					       GFP_KERNEL);
 	if (!interrupt_data->msix_entries) {
-		goto err_alloc;
+		goto err_free_msix;
 	}
 
 	interrupt_data->eventfd_ctxs = kcalloc(num_interrupts,
 					       sizeof(struct eventfd_ctx *),
 					       GFP_KERNEL);
 	if (!interrupt_data->eventfd_ctxs) {
-		goto err_alloc;
+		goto err_free_eventfd;
 	}
 
 	interrupt_data->interrupt_counts = kcalloc(num_interrupts,
 						   sizeof(ulong),
 						   GFP_KERNEL);
 	if (!interrupt_data->interrupt_counts) {
-		goto err_alloc;
+		goto err_free_data;
 	}
 
 	switch (interrupt_data->type) {
@@ -397,10 +397,12 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name,
 
 	return 0;
 
-err_alloc:
-	kfree(interrupt_data);
-	kfree(interrupt_data->msix_entries);
+err_free_msix:
 	kfree(interrupt_data->eventfd_ctxs);
+err_free_eventfd:
+	kfree(interrupt_data->msix_entries);
+err_free_data:
+	kfree(interrupt_data);
 	return -ENOMEM;
 }
 
-- 
2.19.1




^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-31 21:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31 16:47 [PATCH v2] staging: gasket Create a memory allocation path Ioannis Valasakis
2018-10-31 16:54 ` [Outreachy kernel] " Sasha Levin
2018-10-31 20:50   ` Ioannis Valasakis
2018-10-31 20:57     ` Julia Lawall
2018-10-31 21:00       ` Ioannis Valasakis
2018-10-31 21:04         ` Julia Lawall
2018-10-31 20:40 ` Julia Lawall
2018-10-31 20:58   ` Ioannis Valasakis

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.