All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6] staging: gasket: Create a free memory error path
@ 2018-11-01  1:05 Ioannis Valasakis
  2018-11-05 13:44 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Ioannis Valasakis @ 2018-11-01  1:05 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: gregkh, alexander.levin

Create an error handling path for memory allocation. It avoids repeating
the same assignments and returns the respective ENOMEM.

Signed-off-by: Ioannis Valasakis <code@wizofe.uk>
---
Changes in v5:
	- Correct label names to reflect freed memory

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

diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c
index 49d47afad64f..4dbcac4c8e22 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -340,17 +340,14 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
 					       sizeof(struct eventfd_ctx *),
 					       GFP_KERNEL);
 	if (!interrupt_data->eventfd_ctxs) {
-		kfree(interrupt_data);
-		return -ENOMEM;
+		goto err_free_data;
 	}
 
 	interrupt_data->interrupt_counts = kcalloc(driver_desc->num_interrupts,
 						   sizeof(ulong),
 						   GFP_KERNEL);
 	if (!interrupt_data->interrupt_counts) {
-		kfree(interrupt_data->eventfd_ctxs);
-		kfree(interrupt_data);
-		return -ENOMEM;
+		goto err_free_eventfd;
 	}
 
 	switch (interrupt_data->type) {
@@ -379,6 +376,12 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
 				    interrupt_sysfs_attrs);
 
 	return 0;
+
+err_free_eventfd:
+	kfree(interrupt_data->eventfd_ctxs);
+err_free_data:
+	kfree(interrupt_data);
+	return -ENOMEM;
 }
 
 static void
-- 
2.19.1




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

* Re: [PATCH v6] staging: gasket: Create a free memory error path
  2018-11-01  1:05 [PATCH v6] staging: gasket: Create a free memory error path Ioannis Valasakis
@ 2018-11-05 13:44 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2018-11-05 13:44 UTC (permalink / raw)
  To: Ioannis Valasakis; +Cc: outreachy-kernel, alexander.levin

On Thu, Nov 01, 2018 at 01:05:55AM +0000, Ioannis Valasakis wrote:
> Create an error handling path for memory allocation. It avoids repeating
> the same assignments and returns the respective ENOMEM.
> 
> Signed-off-by: Ioannis Valasakis <code@wizofe.uk>
> ---
> Changes in v5:
> 	- Correct label names to reflect freed memory

This is v6, what changed here?

And what about all of the previous versions, what was their history?  No
need to drop it, putting it here is good to see.

v7?  :)

thanks,

greg k-h


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

end of thread, other threads:[~2018-11-05 13:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01  1:05 [PATCH v6] staging: gasket: Create a free memory error path Ioannis Valasakis
2018-11-05 13:44 ` Greg KH

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.