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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 13 May 2013 21:36:50 -0700
From:	Joe Perches <joe@...ches.com>
To:	Ruslan Bilovol <ruslan.bilovol@...com>
Cc:	apw@...onical.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] checkpatch: add check for wrong "if
 (IS_ERR_OR_NULL(<foo>)) return PTR_ERR(<foo>)" uses

On Tue, 2013-05-14 at 03:41 +0300, Ruslan Bilovol wrote:
> This was many times discussed by Russell King
> and I also was about wrong usage of IS_ERR_OR_NULL()
> in my patch. So I added this check and other people will
> be at least warned about potentially wrong usage
> of mentioned macro.
[]
> Tested on:
> +	if (IS_ERR_OR_NULL(soc_dev))
> +		return PTR_ERR(soc_dev);
> +
> +	if (IS_ERR_OR_NULL(soc_dev))en
> +		return soc_dev ? PTR_ERR(soc_dev) : -ENODEV;

I did a grep for IS_ERR_OR_NULL and this misses variants like:

		if (unlikely(IS_ERR_OR_NULL(etc...

Perhaps something like this?
---
 scripts/checkpatch.pl | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b954de5..18c7d8c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2184,6 +2184,15 @@ sub process {
 				WARN("SUSPECT_CODE_INDENT",
 				     "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
 			}
+
+# check for misuses of IS_ERR_OR_NULL
+			if ($stat =~ /^\+.*\bIS_ERR_OR_NULL\s*\(\s*($Lval)\s*\)/) {
+				my $test = $1;
+				if ($stat =~ /\bPTR_ERR\s*\(\s*${test}\s*\)/) {
+					WARN("IS_ERR_OR_NULL",
+					     "Use of IS_ERR_OR_NULL($test) with PTR_ERR($test) is usually wrong: see http://permalink.gmane.org/gmane.linux.ports.arm.omap/97874\n" . $herecurr . "$stat_real\n");
+				}
+			}
 		}
 
 		# Track the 'values' across context and added lines.


--
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