Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755394AbdLVACL (ORCPT ); Thu, 21 Dec 2017 19:02:11 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:59698 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752500AbdLVACI (ORCPT ); Thu, 21 Dec 2017 19:02:08 -0500 Date: Fri, 22 Dec 2017 00:02:07 +0000 From: Al Viro To: Vasyl Gomonovych Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] epoll: fix dereferenced before check pt Message-ID: <20171222000207.GY21978@ZenIV.linux.org.uk> References: <1513871657-11239-1-git-send-email-gomonovych@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1513871657-11239-1-git-send-email-gomonovych@gmail.com> User-Agent: Mutt/1.9.0 (2017-09-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1146 Lines: 24 On Thu, Dec 21, 2017 at 04:54:17PM +0100, Vasyl Gomonovych wrote: > This patch fixes the warning reported by smatch: > > fs/eventpoll.c:889 ep_item_poll() warn: variable dereferenced before check 'pt' ... and of course, that is all the analysis one might want - the tool has spoken. Except that the only thing proven is that the tool is either misused or just plain crappy. Callers of ep_item_poll() are easily found - it's static, so they all are in the same file. All four of them - if (ep_item_poll(epi, &pt, depth)) { revents = ep_item_poll(epi, &epq.pt, 1); if (ep_item_poll(epi, &pt, 1)) { revents = ep_item_poll(epi, &pt, 1); Figuring out why an address of a local variable or of a field thereof can never be NULL is left as an exercise for an introductory course on C. "Fixing warnings" is bloody wrong - warning (from any tool) is a heuristic pointing to a place that might be worth looking into. In cases when you've found a real problem with help from some tool, sure, go ahead and credit that tool in the commit message. Along with the description of the problem you've found.