From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: "Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>
Cc: lidza.louina@gmail.com, markh@compro.net,
gregkh@linuxfoundation.org,
driverdev-devel@linuxdriverproject.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: dgnc: check if kzalloc fails in dgnc_tty_init()
Date: Tue, 7 Apr 2015 16:11:10 +0530 [thread overview]
Message-ID: <20150407104110.GB28119@sudip-PC> (raw)
In-Reply-To: <1428402392-15817-1-git-send-email-giedrius.statkevicius@gmail.com>
On Tue, Apr 07, 2015 at 01:26:32PM +0300, Giedrius Statkevičius wrote:
> kzalloc() could fail so add a check and return -ENOMEM if it does that gets
> propogated to the pci layer
>
> Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
> ---
> drivers/staging/dgnc/dgnc_tty.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
> index 61d5a8e..23337da 100644
> --- a/drivers/staging/dgnc/dgnc_tty.c
> +++ b/drivers/staging/dgnc/dgnc_tty.c
> @@ -311,6 +311,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])
> + return -ENOMEM;
won't this create memory leak ?
suppose you have brd->nasync = 3
and kzalloc fails when i=2, and you return -ENOMEM,
then what happens to the memory already allocated to brd->channels[0]
and brd->channels[1] ?
regards
sudip
next prev parent reply other threads:[~2015-04-07 10:41 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 [this message]
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
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=20150407104110.GB28119@sudip-PC \
--to=sudipm.mukherjee@gmail.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 \
/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