From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>
Cc: lidza.louina@gmail.com, markh@compro.net,
devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
driverdev-devel@linuxdriverproject.org,
linux-kernel@vger.kernel.org, sudipm.mukherjee@gmail.com
Subject: Re: [PATCH v2] staging: dgnc: check if kzalloc fails in dgnc_tty_init()
Date: Tue, 7 Apr 2015 16:01:11 +0300 [thread overview]
Message-ID: <20150407130111.GE10964@mwanda> (raw)
In-Reply-To: <1428410417-18524-1-git-send-email-giedrius.statkevicius@gmail.com>
On Tue, Apr 07, 2015 at 03:40:17PM +0300, Giedrius Statkevičius wrote:
> If one of the allocations of memory for storing a channel information struct
> fails then free all the successful allocations and return -ENOMEM that gets
> propogated to the pci layer. Also, remove a bogus skipping in the next part of
> the initiation if a previous memory allocation failed because we won't execute
> that if any of the allocations failed.
>
> Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
> ---
> v2: Only returning -ENOMEM if an allocation failed isn't enough as it was
> spotted by Sudip so create a new label that frees all successfully allocated
> stuff and only then returns -ENOMEM. Also, remove a unnecessary check in the
> next loop.
>
> drivers/staging/dgnc/dgnc_tty.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
> index ce4187f..60d7e49 100644
> --- a/drivers/staging/dgnc/dgnc_tty.c
> +++ b/drivers/staging/dgnc/dgnc_tty.c
> @@ -316,6 +316,8 @@ int dgnc_tty_init(struct dgnc_board *brd)
> * interrupt context, and there are no locks held.
> */
> brd->channels[i] = kzalloc(sizeof(*brd->channels[i]), GFP_KERNEL);
> + if (!brd->channels[i])
> + goto err_free_channels;
The comments here say that sometimes brd->channels[] are allocated
earlier. If that's true then the error handling is not correct. But
I don't think it is true... Could you investigate and delete the
comments and unnecessary "if (!brd->channels[i])" NULL check.
regards,
dan carpenter
next prev parent reply other threads:[~2015-04-07 13:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 10:26 [PATCH] staging: dgnc: check if kzalloc fails in dgnc_tty_init() Giedrius Statkevičius
2015-04-07 10:41 ` Sudip Mukherjee
2015-04-07 11:53 ` Giedrius Statkevičius
2015-04-07 12:40 ` [PATCH v2] " Giedrius Statkevičius
2015-04-07 13:01 ` Dan Carpenter [this message]
2015-04-07 13:25 ` Giedrius Statkevičius
2015-04-07 14:11 ` [PATCH v3] " Giedrius Statkevičius
2015-04-07 14:24 ` Sudip Mukherjee
2015-04-07 14:37 ` Giedrius Statkevičius
2015-04-07 14:54 ` Dan Carpenter
2015-04-07 14:48 ` Dan Carpenter
2015-04-07 15:35 ` Giedrius Statkevičius
2015-04-07 15:46 ` Dan Carpenter
2015-04-07 16:11 ` [PATCH v4 1/3] staging: dgnc: clean up allocation of ->channels[i] Giedrius Statkevičius
2015-04-09 23:42 ` [PATCH v5 " Giedrius Statkevičius
2015-04-09 23:42 ` [PATCH v5 2/3] staging: dgnc: don't forget to check if ->channels[i] is NULL in dgnc_tty_uninit() Giedrius Statkevičius
2015-04-09 23:42 ` [PATCH v5 3/3] staging: dgnc: remove redundant !ch checks Giedrius Statkevičius
2015-04-07 16:11 ` [PATCH v4 2/3] staging: dgnc: don't forget to check if ->channels[i] is NULL in dgnc_tty_uninit() Giedrius Statkevičius
2015-04-07 16:11 ` [PATCH v4 3/3] staging: dgnc: remove redundant !ch checks Giedrius Statkevičius
2015-04-10 0:37 ` Dan Carpenter
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=20150407130111.GE10964@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=giedrius.statkevicius@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=lidza.louina@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markh@compro.net \
--cc=sudipm.mukherjee@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox