lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 7 Apr 2015 16:01:11 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Giedrius Statkevičius 
	<giedrius.statkevicius@...il.com>
Cc:	lidza.louina@...il.com, markh@...pro.net,
	devel@...verdev.osuosl.org, gregkh@...uxfoundation.org,
	driverdev-devel@...uxdriverproject.org,
	linux-kernel@...r.kernel.org, sudipm.mukherjee@...il.com
Subject: Re: [PATCH v2] staging: dgnc: check if kzalloc fails in
 dgnc_tty_init()

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@...il.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ