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, 2 Dec 2014 10:09:02 +0100 (CET)
From:	Julia Lawall <julia.lawall@...6.fr>
To:	Dan Carpenter <dan.carpenter@...cle.com>
cc:	Jonathan Corbet <corbet@....net>, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
	OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
	SF Markus Elfring <elfring@...rs.sourceforge.net>,
	Coccinelle <cocci@...teme.lip6.fr>
Subject: Re: [patch] CodingStyle: add some more error handling guidelines

> @@ -403,9 +408,10 @@ The rationale is:
>  int fun(int a)
>  {
>  	int result = 0;
> -	char *buffer = kmalloc(SIZE);
> +	char *buffer;
>
> -	if (buffer == NULL)
> +	buffer = kmalloc(SIZE);

kmalloc actually takes two arguments.  Perhaps it would be better to show
something that looks like a valid call.

Otherwise,

Acked-by: Julia Lawall <julia.lawall@...6.fr>

julia

> +	if (!buffer)
>  		return -ENOMEM;
>
>  	if (condition1) {
> @@ -413,14 +419,25 @@ int fun(int a)
>  			...
>  		}
>  		result = 1;
> -		goto out;
> +		goto out_buffer;
>  	}
>  	...
> -out:
> +out_buffer:
>  	kfree(buffer);
>  	return result;
>  }
>
> +A common type of bug to be aware of it "one err bugs" which look like this:
> +
> +err:
> +	kfree(foo->bar);
> +	kfree(foo);
> +	return ret;
> +
> +The bug in this code is that on some exit paths "foo" is NULL.  Normally the
> +fix for this is to split it up into two error labels "err_bar:" and "err_foo:".
> +
> +
>  		Chapter 8: Commenting
>
>  Comments are good, but there is also a danger of over-commenting.  NEVER
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
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