staging: gasket: Create a free memory error path
PATCH v4 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.
---
Changes in v4:
- Rebase against gregkh staging source tree
- Modified the error handling paths to correctly free the respective 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_ctxs; } 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_all; }switch (interrupt_data->type) {
@@ -379,6 +376,12 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev) interrupt_sysfs_attrs);return 0 ; + +err_free_counts: +kfree (interrupt_data->eventfd_ctxs); +err_free_ctxs: +kfree (interrupt_data); +return -ENOMEM ; } static void
Signature · 1 line
2.19.1
Quoted 24 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 v4:
- Rebase against gregkh staging source tree
- Modified the error handling paths to correctly free the respective memory
drivers/staging/gasket/gasket_interrupt.c| 13 ++++++++-----1 file changed, 8 insertions(+), 5 deletions(-)drivers/staging/gasket/gasket_interrupt.c +1
-2@@ -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_ctxs;
drivers/staging/gasket/gasket_interrupt.c int gasket_interrupt_init(struct gasket_dev *gasket_dev) · line 350
Quoted 10 lines
drivers/staging/gasket/gasket_interrupt.c +1
-3} 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_all;
Does this label exist?
julia
Quoted 27 lines
drivers/staging/gasket/gasket_interrupt.c +6
-1}switch (interrupt_data->type) {@@ -379,6 +376,12 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev) interrupt_sysfs_attrs);return 0 ; + +err_free_counts: +kfree (interrupt_data->eventfd_ctxs); +err_free_ctxs: +kfree (interrupt_data); +return -ENOMEM ; } static void --2.19.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20181031212220.GA24472%40kvasir.local.
For more options, visit https://groups.google.com/d/optout.