From nobody Tue Sep 29 13:39:31 2026 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D4DC244694 for ; Sun, 9 Aug 2026 16:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786294507; cv=none; b=PWWXwxyCYRFHA49g4kJVXA0nh/WzSW3JDX6pe5ZXnOOENtdc0qFz7G2k436yIYOCVYy0ICus2BBJZT0zteK2dQqSjShFVL3wg9OaMhZL12x3G5zYGslsWaLbUnhnkjFdQSxdrCLx5t4cLB8ICECZAEV2HNC2xxgwrK2b/Ci2BSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786294507; c=relaxed/simple; bh=wQ6SruKpgjeIJFj6mDq8NAd1sf7/EB4+5HW/Jh0Ya58=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZUHlB4GTVnFsJ3r0qkLoa2I7L7xBqfVybLP5s7dm4gYNhsVQJkk5XguEEi3lWPKUAm07vkbr15/eThDXpjGWiickhPkXlXuX4b9YECQ/8Woh0EmuDTK9wRDHniEPtUA/7Dgy7c8x6E26d6CdQWl1EKB+bF0uTIIL95/jHttvidA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=FeI/61X9; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="FeI/61X9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=DKhMoDE1vjjp/Bzti/o7BbIkPBVU8A/Do/SECguGYkA=; b=FeI/61X94h0T4YN8N3XBX94tSl65WYC1h37M8dAVBGyagTUdNBlS705k cjn0lxCE1W58q2A7ZNHqGESUrv7ovGBjJ2J/3kA/Gxe5C8TnEjZOVTZpH uNwYjG9GInv4Y/UFJiM8WCAyIOeOpdCdwUBL1W0YkySIIg/ccIeKV8aHH o=; X-CSE-ConnectionGUID: GVEKbVYtQ12viG2atoAnrw== X-CSE-MsgGUID: tjk0pRixQkeqdfjTG4XYSw== Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.25,214,1779141600"; d="scan'208";a="289600684" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.102.196]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2026 18:53:52 +0200 From: Julia Lawall To: Julia Lawall Cc: Nicolas Palix , cocci@inria.fr, linux-kernel@vger.kernel.org, Ricardo Ribalda Subject: [PATCH] coccinelle: scripts: coccinelle: devm_free: reduce false positives Date: Sun, 9 Aug 2026 18:53:40 +0200 Message-Id: <20260809165340.1719736-1-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" False positives could be introduced due to allocations using the new _obj functions. Add these to the "safe" rule accordingly. False positives could also be introduced when the same variable name has two possible types. Incorporate type informationt to avoid reporting this case This does lead to false negatives when no type information is available. Signed-off-by: Julia Lawall Reported-by: Ricardo Ribalda --- scripts/coccinelle/free/devm_free.cocci | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/f= ree/devm_free.cocci index 0880729ba..947d7e685 100644 --- a/scripts/coccinelle/free/devm_free.cocci +++ b/scripts/coccinelle/free/devm_free.cocci @@ -26,7 +26,8 @@ virtual report virtual context =20 @r depends on context || org || report@ -expression x; +type T; +T x; @@ =20 ( @@ -56,18 +57,26 @@ expression x; ) =20 @safe depends on context || org || report exists@ -expression x; +r.T x; position p; @@ =20 ( x =3D kmalloc(...) +| + x =3D kmalloc_obj(...) +| + x =3D kmalloc_objs(...) | x =3D kvasprintf(...) | x =3D kasprintf(...) | x =3D kzalloc(...) +| + x =3D kzalloc_obj(...) +| + x =3D kzalloc_objs(...) | x =3D kmalloc_array(...) | @@ -105,7 +114,7 @@ position p; ) =20 @pb@ -expression r.x; +r.T r.x; position p !=3D safe.p; @@