Received: by 10.223.176.5 with SMTP id f5csp2558589wra; Thu, 1 Feb 2018 02:20:13 -0800 (PST) X-Google-Smtp-Source: AH8x224VLrUAQ/5lXXBxoiclKQxelpCswPr2iQDI9E0+MF8TTJwvJt5qNG96nfBQp4lFffDNl5Xi X-Received: by 2002:a17:902:7581:: with SMTP id j1-v6mr10177340pll.86.1517480413345; Thu, 01 Feb 2018 02:20:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517480413; cv=none; d=google.com; s=arc-20160816; b=e4/tWsYxvoTYSmNL7v1txGhM6YJjKmbPV772ZDw27JC49CC3PGNgWwN11cA4s6+HOe d+x46DKKcqnClrzsmE6rrTkk2+Wu9vGQjr2vPe1FLghDgzk5aGfE7Mw61WpK0F5mef3A DqJ/0BotpQaPYX5eSQfYz2u2OlODpdKZPiwvvj7BNFzEEoAKZBbEfIPQL6n3w4eCqyXb yDenQeOR0w7kT5XcXs9bVP83BrTfvth7YdGDIqS0pD9jiT1DOOh4/NOuMVLtAPZb84z4 bOh+XOXXDZBmca5NglOPdp/JClhlbcVjdQhgDSHG+VplsnVhNN7zS8Df64fGQw0VeRP1 qnRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=U54jqeHpUXi67NIt5+8xteCZeQ63E6/58aAstb+YciY=; b=wqyNZhsxgdJAOhiGUKOQJUPSs5WL2C9hBVQFtAtA3SPV4HbUh/fcylUKucanUhHTfs DZW0K8jy5RCmnNy0qsdOnb75DTbb1G/0xKv+HlGytg08zOFYJ+Y0F2tW0ekmX+7PWMXC 0jDrJifIg43/IFKxtl8tE6SV55Ru/iKiA3q7SPzov+6HOeD/W0zGG/L64KycSR8ex4uc Vzuu+4wsehvmnqXBgWgUuFktZ42ERzOuN0rp6zylEfslt+qBgyfefkStH7oXRiwzm74e vk5FF/f9casIRNATHz+zID1h6Ur0pPyb7yQGq9fZA47xTFxPtLGduNxmrPPxWiknOUwY O6ZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c193si7470508pfc.90.2018.02.01.02.19.58; Thu, 01 Feb 2018 02:20:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752119AbeBAKSK (ORCPT + 99 others); Thu, 1 Feb 2018 05:18:10 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:47600 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbeBAKSJ (ORCPT ); Thu, 1 Feb 2018 05:18:09 -0500 X-IronPort-AV: E=Sophos;i="5.46,443,1511823600"; d="scan'208";a="311588504" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA256; 01 Feb 2018 11:18:06 +0100 From: Julia Lawall To: Masahiro Yamada Cc: kernel-janitors@vger.kernel.org, Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: [PATCH] coccinelle: reduce false positives Date: Thu, 1 Feb 2018 10:48:52 +0100 Message-Id: <1517478532-5444-1-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some files use both a non-devm allocation and a devm_allocation. Don't complain about a free when the same function contains a non-devm allocation. Signed-off-by: Julia Lawall --- scripts/coccinelle/free/devm_free.cocci | 55 +++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci index c990d2c..b2a2cf8b 100644 --- a/scripts/coccinelle/free/devm_free.cocci +++ b/scripts/coccinelle/free/devm_free.cocci @@ -56,9 +56,62 @@ expression x; x = devm_ioport_map(...) ) +@safe depends on context || org || report exists@ +expression x; +position p; +@@ + +( + x = kmalloc(...) +| + x = kvasprintf(...) +| + x = kasprintf(...) +| + x = kzalloc(...) +| + x = kmalloc_array(...) +| + x = kcalloc(...) +| + x = kstrdup(...) +| + x = kmemdup(...) +| + x = get_free_pages(...) +| + x = request_irq(...) +| + x = ioremap(...) +| + x = ioremap_nocache(...) +| + x = ioport_map(...) +) +... +( + kfree@p(x) +| + kzfree@p(x) +| + __krealloc@p(x, ...) +| + krealloc@p(x, ...) +| + free_pages@p(x, ...) +| + free_page@p(x) +| + free_irq@p(x) +| + iounmap@p(x) +| + ioport_unmap@p(x) +) + @pb@ expression r.x; -position p; +position p != safe.p; @@ (