Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp426791imj; Sat, 16 Feb 2019 03:34:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IZEqMSJRxSB2zhqqe6tBtFsUW4Y1bnPRQD21sX86uM2Y70dqOYunvyk6L/BF2SiLZf7ozpm X-Received: by 2002:a17:902:bc81:: with SMTP id bb1mr14804745plb.223.1550316880318; Sat, 16 Feb 2019 03:34:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550316880; cv=none; d=google.com; s=arc-20160816; b=z6mnIVv7Wrr1VIktkOs31kUAQIhn0Fd9ZjEB9FKIoMQn1ZW82EGHC7KygmG9SgWxrP uUVS4A37zMhlv2dDhlzIAad2d1DfI9H5OsdkzvIolGJyIWtxwgqpUoNSwUavK9y0A33J RYTbjdJ92pfuIGq51voQmzIw2zHLLjQlaiACaLkiLjzUno5UIsFStSQv8/d2bKtuP5Z9 NN83Dk16JWCqe7VkL6F/LNPROlQf5+g2gh/dhtQ7EVkqiIhUZO3e8aJYSsUXq3CKu1ma xYdc99jXlb7Jk/WmzhK/aqRN7iOCcWPlRiUJE8H/vE65cXzMNZKYolf3nw6wyXs4KLzf a2aA== 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=zUKa1tqI/CojBlY3WOpFK855TIAYHrJ7R1KMrn6zNOU=; b=zLwXHpA+w2hqip9+5Wsp/dhZGnewxrOtB6GM2sTXWkdWtxeq+wBbfzDdCzEmvt8FcS n1AMiA/9zjUqiPlOFeCZmihEtCijAWEcScgw4dLM4CGSWzthq3MnGFMLFJCQcuUuK+JD 96YmKMJ40nlgYBHaoX0ZtN6q58jhuZwoQ6ByB+OxciIhunqyoyMi0uyqbiGyKbCj+qHw FgCXt4+GVnD8SX2rcKjl1nBB/kpt68tZhnVTG/QsYFmBXHtJiOP40SIdYWNXlRjyfW6c USM5IhwEXAT2YgXBGsz6aYU6kAd6LPhhoxSUpbwOxIcNg3O9nDxA84Eg3SSOly4gnVTa UsWw== 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 y14si8252567pgo.363.2019.02.16.03.34.20; Sat, 16 Feb 2019 03:34:40 -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 S1729808AbfBPIJS (ORCPT + 99 others); Sat, 16 Feb 2019 03:09:18 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:38917 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727724AbfBPIJS (ORCPT ); Sat, 16 Feb 2019 03:09:18 -0500 X-IronPort-AV: E=Sophos;i="5.58,375,1544482800"; d="scan'208";a="296375171" Received: from abo-58-107-68.mrs.modulonet.fr (HELO hadrien) ([85.68.107.58]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2019 09:09:15 +0100 Date: Sat, 16 Feb 2019 09:09:14 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: wen.yang99@zte.com.cn cc: Markus.Elfring@web.de, Gilles Muller , nicolas.palix@imag.fr, michal.lkml@markovi.net, wang.yi59@zte.com.cn, yamada.masahiro@socionext.com, yellowriver2010@hotmail.com, cheng.shengyu@zte.com.cn, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [v5] Coccinelle: semantic code search for missing put_device() In-Reply-To: <201902161529041506841@zte.com.cn> Message-ID: References: 1550217319-40418-1-git-send-email-wen.yang99@zte.com.cn,b2f195e8-c3a3-f876-a075-317bb33496c6@web.de <201902161529041506841@zte.com.cn> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-938833334-1550304555=:3212" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-938833334-1550304555=:3212 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Sat, 16 Feb 2019, wen.yang99@zte.com.cn wrote: > >>> Does the first SmPL when specification include the case that a call > >>> of the function “put_device” can occur within a branch of an if statement? > >> > >> It does include that, > > > >Thanks for this acknowledgement. > > > >So it seems that you find my interpretation of this bit of SmPL code appropriate. > > > >> but there is another execution path where the put device is not present. > > > >It is tried to find such cases. > > > >> But given the test in the if in the when code, > >> on that execution path id is NULL, an so there is no need to put it. > > > >I would like to point out that the function “put_device” belongs also to > >the category of functions which tolerate the passing of null pointers. > >https://elixir.bootlin.com/linux/v5.0-rc6/source/drivers/base/core.c#L2053 > >https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/core.c?id=cb5b020a8d38f77209d0472a0fea755299a8ec78#n2053 > > > >Have we got still different software development opinions about the need > >for an extra pointer check in the “second” SmPL when specification? > > Thanks to Julia and Markus. > We will modify the the if in the when code like this: > > @@ -22,7 +22,7 @@ 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 != if (...) { ... put_device(&id->dev) ... } This looks ok. You can check the old version and the new version and see if there is any differencein the set of reports. julia --8323329-938833334-1550304555=:3212--