staging: gasket: Create a free memory error path
PATCH v6 1/1 staging: gasket: Create a free memory error path
Create an error handling path for memory allocation. It avoids repeating the same assignments and returns the respective ENOMEM.
Signed-off-by Ioannis Valasakis <[email protected]>
---
Changes in v5:
- Correct label names to reflect freed memory
drivers/staging/gasket/gasket_interrupt.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
drivers/staging/gasket/gasket_interrupt.c +8 -5
@@ -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
Signature · 1 line
2.19.1
Greg KH
maintainerQuoted 7 lines · Ioannis Valasakis
Create an error handling path for memory allocation. It avoids repeating the same assignments and returns the respective ENOMEM.
Signed-off-by Ioannis Valasakis <[email protected]>---
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