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=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable 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 0A4B2C4741F for ; Sat, 26 Sep 2020 14:55:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1C8C20BED for ; Sat, 26 Sep 2020 14:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601132127; bh=5tMbBNIJtzVNaEG/loFu6mje1p8enh0WBS5iNeCs55k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=DI2KGZMhyrFjbuNc4QSlEbPSN4t22U8uIRm5vLUatgHAvK6NPBJL58LChcxZa0vZB RkBh1NRH9BdZ6CROZyok3rcQBOCiBS1rbFod4hbluBQ2PfwonTU7hjiGrZg5HskzRb hfXu6t33kD2RK1aHnDCEiScpZgRoFuCy6JXbQdoY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729473AbgIZOz0 (ORCPT ); Sat, 26 Sep 2020 10:55:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:44216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729186AbgIZOz0 (ORCPT ); Sat, 26 Sep 2020 10:55:26 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B26B320882; Sat, 26 Sep 2020 14:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601132126; bh=5tMbBNIJtzVNaEG/loFu6mje1p8enh0WBS5iNeCs55k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qr4QpinhYLaSk7qWaLIGr9oO9V86HUNQag9yGWGGgY/WNln1XzTST+bRp1bEp90W5 mEAZJk7HCwxTjk2KfaNzgDIawYUwqfndhcdwFL3nEEL5lwnhc/VFHNTdnB/LlDwQZ1 LLah1bytFo+78NGbYdXzQXEJA05+jpl/5qyG6jB4= Date: Sat, 26 Sep 2020 15:55:21 +0100 From: Jonathan Cameron To: Markus Elfring Cc: Tobias Jordan , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Lars-Peter Clausen , Nuno Sa , Peter Meerwald-Stadler Subject: Re: [PATCH] iio: temperature: ltc2983: fix leak of device node iterator Message-ID: <20200926155521.3b75342f@archlinux> In-Reply-To: References: X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 26 Sep 2020 16:45:56 +0200 Markus Elfring wrote: > > Thought about adding an "goto err_of_node_put" instead, but as the error > > paths are quite divergent, I'm not sure if that wouldn't complicate > > things. =20 >=20 > Please add jump targets like =E2=80=9Ce_inval=E2=80=9D and =E2=80=9Cput_n= ode=E2=80=9D so that a bit of > common exception handling code can be better reused for this function imp= lementation. > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/D= ocumentation/process/coding-style.rst?id=3D7c7ec3226f5f33f9c050d85ec20f1841= 9c622ad6#n475 On this one I think readability would perhaps be hurt a little by doing so, particular as we need to do the of_put_node in some but not all non error paths. =20 It is a close run thing between the two options however. I considered another option of suggesting factoring out this whole per node block, but to do that we would have to do something a bit odd with the return value as we have 3 options. * error * do not parse any more children. * continue to parse children. So I think in this case Tobias' solution is the best one available. Thanks, Jonathan >=20 > Regards, > Markus From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Cameron Date: Sat, 26 Sep 2020 14:55:21 +0000 Subject: Re: [PATCH] iio: temperature: ltc2983: fix leak of device node iterator Message-Id: <20200926155521.3b75342f@archlinux> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: Markus Elfring Cc: Tobias Jordan , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Lars-Peter Clausen , Nuno Sa , Peter Meerwald-Stadler On Sat, 26 Sep 2020 16:45:56 +0200 Markus Elfring wrote: > > Thought about adding an "goto err_of_node_put" instead, but as the error > > paths are quite divergent, I'm not sure if that wouldn't complicate > > things. > > Please add jump targets like “e_inval” and “put_node” so that a bit of > common exception handling code can be better reused for this function implementation. > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=7c7ec3226f5f33f9c050d85ec20f18419c622ad6#n475 On this one I think readability would perhaps be hurt a little by doing so, particular as we need to do the of_put_node in some but not all non error paths. It is a close run thing between the two options however. I considered another option of suggesting factoring out this whole per node block, but to do that we would have to do something a bit odd with the return value as we have 3 options. * error * do not parse any more children. * continue to parse children. So I think in this case Tobias' solution is the best one available. Thanks, Jonathan > > Regards, > Markus