Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1441335imj; Sun, 17 Feb 2019 06:03:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IZx2gmRRTR7PvMu74VeG2pN3d7/Fs8q0ZNQr77Hf3CS6L/zI+Q/s+F1DHn5TCk17eVl6axI X-Received: by 2002:a63:f552:: with SMTP id e18mr14377362pgk.239.1550412202527; Sun, 17 Feb 2019 06:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550412202; cv=none; d=google.com; s=arc-20160816; b=GJ5B2543ZwfVRafQOflXiEzudS6GRO8W+qG7cbIzs97Z0GFjnx2GheVX16i69VgLyB 9rYUhQlsZZGwtuWcuntmwvARtfuSOnWGLtYjKv1+YWcbaXkP9W/1Ea6rGkruoaf8h95R wfX+owR/Wnj1FaTJs71TBnHYvV9lr5tzxYRlG55YK52uAk3PipV42H0Fbk56UsUvCVJ6 y30bit7ULjaWuFCtYJmeZ9KCIsM7IfPcE4vE+i0RNcbTjzwtx1Q9++0wblh0vvh9K6bS a98cOHHGuG5ngwH91RJrZnvkEoVE3fiYxDsfuNUyKefK59NTLdG/AW+cMa91qCaqYa5+ m3yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=rzG7YFKszL7MqvbFv/n5T5JnbqyPF7ifkkGu6N01/D4=; b=MgxMtO2zo9aqq4jXezVFsUnBTJPs3AqmxaqfmzaZGUyUxUNghyfjr7VA32Ilc0c1Un AkfJhefvubvH6Ul15XNooy1x7kn76Wun4LdqouOx314MKKfc39KPCjAnGwQdr7ePS+Xk 5Fg93lq5JOF3FDRvUNN7xyF+xGD+UA+g6E7lbVU3jtPRxtH0zCbX2D6U3SkHjIhxqQSt PAMncxFMwWcL/rx6MaI69uRe+PC/eop5HeyR00GsaAgsMhvyCvwSZq1cBFFd0leo67QF Dg2eeTATqSuNkCiVsuJw+dKVAwUvVJf3PT/iE1pX6MkREoPLIiEnrfOnyBajEq6yPD7u eCew== 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 h10si9810569pgp.4.2019.02.17.06.03.05; Sun, 17 Feb 2019 06:03:22 -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 S1728125AbfBQLhU (ORCPT + 99 others); Sun, 17 Feb 2019 06:37:20 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:12380 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbfBQLhU (ORCPT ); Sun, 17 Feb 2019 06:37:20 -0500 X-IronPort-AV: E=Sophos;i="5.58,380,1544482800"; d="scan'208";a="369731283" Received: from abo-58-107-68.mrs.modulonet.fr (HELO hadrien) ([85.68.107.58]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2019 12:37:18 +0100 Date: Sun, 17 Feb 2019 12:37:18 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Markus Elfring cc: Wen Yang , Gilles Muller , Nicolas Palix , Michal Marek , Masahiro Yamada , Wen Yang , Cheng Shengyu , kernel-janitors@vger.kernel.org, LKML , Coccinelle Subject: Re: [PATCH v6] coccinelle: semantic code search for missing put_device() In-Reply-To: <8e7ba7c0-b7fe-a1f0-d28b-0c716ecbcfdb@web.de> Message-ID: References: <8e7ba7c0-b7fe-a1f0-d28b-0c716ecbcfdb@web.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 17 Feb 2019, Markus Elfring wrote: > > +@search exists@ > > +local idexpression id; > > +expression x,e,e1; > > +position p1,p2; > > +type T,T1,T2; > > +@@ > > + > > +id = of_find_device_by_node@p1(x) > > +... when != e = id > > I suggest to increase your software development attention also for > another implementation detail. > Source code analysis triggers challenges for safe data flow handling. > the semantic patch language supports search specifications for > the exclusion of specific assignments. > > Does this SmPL code contain a questionable order for the source > and target metavariables? > Can the following variant be more appropriate? > > + ... when != id = e This is possible, but I think unlikely. > > > > +if (id == NULL || ...) { ... return ...; } > > +... when != put_device(&id->dev) > > + when != platform_device_put(id) > > + when != of_dev_put(id) > > + when != if (id) { ... put_device(&id->dev) ... } > > + when != e1 = (T)id > > Would you like to avoid that the return value from the shown function call > gets overwritten in the variable before it was used once at least > (when a bit of extra C code is tolerated before a null pointer check)? Indeed there should be a put then too, but again, it seems unlikely. julia > > Regards, > Markus >