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:	Wed, 20 May 2015 22:51:34 +0000
From:	"Dilger, Andreas" <andreas.dilger@...el.com>
To:	Dan Carpenter <dan.carpenter@...cle.com>
CC:	"open list:STAGING SUBSYSTEM" <devel@...verdev.osuosl.org>,
	Julia Lawall <Julia.Lawall@...6.fr>,
	Adrian Remonda <adrianremonda@...il.com>,
	open list <linux-kernel@...r.kernel.org>,
	"Drokin, Oleg" <oleg.drokin@...el.com>,
	Greg Donald <gdonald@...il.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"moderated list:STAGING - LUSTRE..." <HPDD-discuss@...1.01.org>,
	Joe Perches <joe@...ches.com>
Subject: Re: [PATCH 4/4] Staging: lustre: sparse lock warning fix

On 2015/05/20, 1:42 PM, "Dan Carpenter" <dan.carpenter@...cle.com> wrote:

>In Smatch, it the equivalent warning is turned off by default because
>there are too many false positives, but you can enable it with the
>--spammy flag.
>
>kchecker --spammy drivers/staging/lustre/lustre/ptlrpc/nrs.c
>
>drivers/staging/lustre/lustre/ptlrpc/nrs.c:512 nrs_resource_put_safe()
>warn: 'spin_lock:&nrs->nrs_lock' is sometimes locked here and sometimes
>unlocked.

Would this be happier with something like:

        for (i = 0; i < NRS_RES_MAX; i++) {
		if (pols[i] == NULL)
			continue;
        

		if (nrs == NULL) {
			nrs = pols[i]->pol_nrs;
			if (likely(nrs != NULL)) /* make sparse happy */
				spin_lock(&nrs->nrs_lock);
		}
		nrs_policy_put_locked(pols[i]);
	}

	if (nrs != NULL)
	spin_unlock(&nrs->nrs_lock);

so that the "if" conditions are the same?  The code definitely doesn't
have a bug, because the lock is only locked once when nrs is first set,
and only unlocked if it is set.  Or is there a comment to put there that
will quiet the static checker?


Cheers, Andreas
-- 
Andreas Dilger

Lustre Software Architect
Intel High Performance Data Division


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