From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16A18C4361B for ; Tue, 15 Dec 2020 19:38:06 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1833225A9 for ; Tue, 15 Dec 2020 19:38:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1833225A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7GhWCsgyZxQSQC8w7fqAgFmNSmkPD//JiJh7fImSfBc=; b=DyR1dSGXF+hg3rGVgFlwbGr9U Yb0SkqZR+hOkXipoga5swpE/VgtaMi3yn+OGKUV7pVr5mMya9P6w5yl3OY6Az75YiO1lDCBEqYgv/ xYjjdfcgiXHKRFugY133I1UkXP8vPPF8LcXPyBrlBvsY6opCds2ngZECokz9MthSlo6y3Ccc0v+oD RNUfDdNAnt8UYW6fo5BrQapTWnQQAakIsddH1Zn+v1wk1/VTaCsqBNwk64Jh+9K/e5ILQfUck7oH0 AXq5yCm8NCjOKez3hrSN5tdlv6OhFiCNY6kCu/K/xYUmScEOH3G84ktfeqGoTNmD1iLGMQy+p9Dx7 lzI9X4fWQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpG7k-0003IL-9w; Tue, 15 Dec 2020 19:36:40 +0000 Received: from aserp2120.oracle.com ([141.146.126.78]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpG7g-0003HV-VF for linux-arm-kernel@lists.infradead.org; Tue, 15 Dec 2020 19:36:39 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BFJXwiL157506; Tue, 15 Dec 2020 19:36:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=corp-2020-01-29; bh=YobLz1Ds6I8pWJCq3iLIbappGSFWxMPj1YhXwhj5bK4=; b=HvhaK+z28o/dtjhUO9+IRDBxSG/1x/A0TYzok3gy2bTcEG9rRa8IAD/qVmJiykGXkvGH x51xkKBoF8yYFdZ4ls9A27+//Mb1gdf9aBZpkp7PLjPYjdhZaTwlf1xmWn2MBQ3e4Tb+ KlNqw3adH8HMI3+ESkqx/uOtAoIR0NLBFVGJscTYt8F2ueGGebGSDmHkBxCzNrnBX67H 6stEBUKWqUcSEll7il/g1I7cclihxDhgWtrQHri02l8gleZ9aB0nRc1Y926mZU6NnE0N pt6lrb4LOdhL8J4h+xJMUkMLGXW8slHm7vq/VfDwB2lTig1HuYED/ewC5pG7nXRHWZxc 7A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 35cntm4dwy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 15 Dec 2020 19:36:02 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BFJZ83J009610; Tue, 15 Dec 2020 19:36:01 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 35e6jrmas5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Dec 2020 19:36:01 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0BFJZvrs016736; Tue, 15 Dec 2020 19:35:57 GMT Received: from kadam (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 Dec 2020 11:35:56 -0800 Date: Tue, 15 Dec 2020 22:35:45 +0300 From: Dan Carpenter To: Maxime Ripard Subject: Re: [PATCH] net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function Message-ID: <20201215193545.GJ2809@kadam> References: <20201214202117.146293-1-christophe.jaillet@wanadoo.fr> <20201215085655.ddacjfvogc3e33vz@gilmour> <20201215091153.GH2809@kadam> <20201215113710.wh4ezrvmqbpxd5yi@gilmour> <54194e3e-5eb1-d10c-4294-bac8f3933f47@wanadoo.fr> <20201215190815.6efzcqko55womf6b@gilmour> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201215190815.6efzcqko55womf6b@gilmour> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9836 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012150130 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9836 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012150130 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201215_143637_120918_6A9582FE X-CRM114-Status: GOOD ( 32.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: song.bao.hua@hisilicon.com, jernej.skrabec@siol.net, f.fainelli@gmail.com, leon@kernel.org, timur@kernel.org, netdev@vger.kernel.org, wangyunjian@huawei.com, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, wens@csie.org, Christophe JAILLET , kuba@kernel.org, sr@denx.de, davem@davemloft.net, linux-arm-kernel@lists.infradead.org, hkallweit1@gmail.com Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Dec 15, 2020 at 08:08:15PM +0100, Maxime Ripard wrote: > On Tue, Dec 15, 2020 at 07:18:48PM +0100, Christophe JAILLET wrote: > > Le 15/12/2020 =E0 12:37, Maxime Ripard a =E9crit=A0: > > > On Tue, Dec 15, 2020 at 12:11:53PM +0300, Dan Carpenter wrote: > > > > On Tue, Dec 15, 2020 at 09:56:55AM +0100, Maxime Ripard wrote: > > > > > Hi, > > > > > = > > > > > On Mon, Dec 14, 2020 at 09:21:17PM +0100, Christophe JAILLET wrot= e: > > > > > > 'irq_of_parse_and_map()' should be balanced by a corresponding > > > > > > 'irq_dispose_mapping()' call. Otherwise, there is some resource= s leaks. > > > > > = > > > > > Do you have a source to back that? It's not clear at all from the > > > > > documentation for those functions, and couldn't find any user cal= ling it > > > > > from the ten-or-so random picks I took. > > > > = > > > > It looks like irq_create_of_mapping() needs to be freed with > > > > irq_dispose_mapping() so this is correct. > > > = > > > The doc should be updated first to make that clear then, otherwise we= 're > > > going to fix one user while multiples will have poped up > > > = > > > Maxime > > > = > > = > > Hi, > > = > > as Dan explained, I think that 'irq_dispose_mapping()' is needed becaus= e of > > the 'irq_create_of_mapping()" within 'irq_of_parse_and_map()'. > > = > > As you suggest, I'll propose a doc update to make it clear and more fut= ure > > proof. > = > Thanks :) > = > And if you feel like it, a coccinelle script would be awesome too so > that other users get fixed over time > = > Maxime Smatch has a new check for resource leaks which hopefully people will find useful. https://github.com/error27/smatch/blob/master/check_unwind.c To check for these I would need to add the following lines to the table: { "irq_of_parse_and_map", ALLOC, -1, "$", &int_one, &int_max}, { "irq_create_of_mapping", ALLOC, -1, "$", &int_one, &int_max}, { "irq_dispose_mapping", RELEASE, 0, "$"}, The '-1, "$"' means the returned value. irq_of_parse_and_map() and irq_create_of_mapping() return positive int on success. The irq_dispose_mapping() frees its zeroth parameter so it's listed as '0, "$"'. We don't care about the returns from irq_dispose_mapping(). It doesn't apply in this case but if a function frees a struct member then that's listed as '0, "$->member_name"'. regards, dan carpenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel