From: Ioannis Valasakis <code@wizofe.uk>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: outreachy-kernel@googlegroups.com, gregkh@linuxfoundation.org,
alexander.levin@microsoft.com
Subject: Re: [Outreachy kernel] [PATCH v5] staging: gasket: Create a free memory error path
Date: Wed, 31 Oct 2018 22:02:43 +0000 [thread overview]
Message-ID: <20181031220243.GA21269@kvasir.local> (raw)
In-Reply-To: <alpine.DEB.2.21.1810312244040.5416@hadrien>
On Wed, Oct 31, 2018 at 10:45:33PM +0100, Julia Lawall wrote:
>
>
> On Wed, 31 Oct 2018, 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:
> > - Typo on the error handling label
>
> Compilation should have found this error.
It would indeed but it still's going on since an hour now so I wanted to
get your feedback meanwhile and understand my mistakes! Me rushing isn't
good but after it compiles with all the new changes I should have a very
fast turnaround :)
>
> > 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..1a3e8b17e714 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_ctxs;
>
> Your labels describe where you are coming from. Dan suggests to make the
> labels descibe what will happen when you get there. Here you aren't going
> to be freeing ctxs. That is the allocation that failed.
>
In that case is err_free_eventfd and err_free_data a good naming scheme?
ta
Ioannis
> julia
>
> > }
> >
> > 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_counts;
> > }
> >
> > 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 outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20181031213742.GA18868%40kvasir.local.
> > For more options, visit https://groups.google.com/d/optout.
> >
next prev parent reply other threads:[~2018-10-31 22:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-31 21:37 [PATCH v5] staging: gasket: Create a free memory error path Ioannis Valasakis
2018-10-31 21:45 ` [Outreachy kernel] " Julia Lawall
2018-10-31 22:02 ` Ioannis Valasakis [this message]
2018-11-01 4:36 ` Himanshu Jha
2018-11-01 6:27 ` Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181031220243.GA21269@kvasir.local \
--to=code@wizofe.uk \
--cc=alexander.levin@microsoft.com \
--cc=gregkh@linuxfoundation.org \
--cc=julia.lawall@lip6.fr \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.