From patchwork Thu Sep 26 16:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13813508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3BF92CDE021 for ; Thu, 26 Sep 2024 16:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EJWKgDcwHDzRJDVWC4NU1waaLgU2pU4Iy2cHBRbpC9w=; b=sMzZgejwtplhjcR/10ZTx1waTm vzn+Dik3Z//X2jCLfpK6R4Vu3eZ+c/SBwZNVzIhrmBkmQ9b78CmdVh9U1201ckGPTGrk0PcBssH1a Cja95Ku9zbKw0Dy/u7x5FaIxNeCV2kW848bpMLmDELsmkmeIkcFjY81yGF90KCtwEFfrlvjmj/XKF ImhDNKsPagocNPO83a+0XPBJIUl9V1W4kXRYkOWJOvRIMhbEjJq00/nC0yKPYGSyQUkZSpBR5C4Pl Zy/mfsrC0HRUnWYofZhWWZ0vb2+10MINL36iPD5SgSKEoxEQBxareWM4Got6Tq5uMYvXJpYEuSSdk B5WqG5gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1strAF-00000008rc4-3LDK; Thu, 26 Sep 2024 16:16:23 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1str2t-00000008qMp-0XRV for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 16:08:48 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a93c1cc74fdso31418466b.3 for ; Thu, 26 Sep 2024 09:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366925; x=1727971725; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EJWKgDcwHDzRJDVWC4NU1waaLgU2pU4Iy2cHBRbpC9w=; b=f/oE1hRXusa9DwYT6FK3lNmXXjTdNhVEjFNfmRNSS0BNb+YsmGy/tqBSLuRKhjOfIg T9tz8LEsysX5Ib1+jT36lYoAdv/Z6j+2QNmI7QkGM9RxmmeeLXwIxWlHS/Z5W7MM+sDP 5cwcIi7ByaRoBUWmGoxYUXhCVv1sSTd6+TZmYPtQ3JZbvizgCRSmNi4iL6qayzXa7G6C vTaIxU4SUm8xT485Cf30DPGWQFDpsTk5TVeUp6aJ/1IJ9uStTUNFhZxJ+djNPs2YAGYk J4KFjh6egQx75SrvJybL2BoxXCGRP2SZg9511N8mwOy4ofYa+reaWU0hCXbzI5hXmA+G VJOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727366925; x=1727971725; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EJWKgDcwHDzRJDVWC4NU1waaLgU2pU4Iy2cHBRbpC9w=; b=Evj/V8seNRoVMstWGH4DanCQ6oJARoRqmZ2yFSb+PGOlYCzziAlIMkSTr+LWaCXvnc NbRWi0FOuhdJ3DiGfo2AicChiUCzRE80PXd7mJbSC5c4Ngup4kWSHs4h1Yxrb3696U2B VG9AL4DWJxomKfJI/Q4GyrnznWxMBQGWMuHJz8ffi0Xgavz5p263PHf0LDF4VIG3dzKb 7U6GJ8coBXOKy40RAVe8DIiKIiYjk60iiCjZZFFQF3OikIdHwbZpX8R5YzJDWZ3K856r dFlzMDPD5dUXkGProX2SG5WysFZXEqTwojWEyuauDU+V606k2jjNeHcJPwwZZiLk16LD Gv5g== X-Forwarded-Encrypted: i=1; AJvYcCWaw1ZvTO/BsNqLumfvXQE4Lsn/dCn5B9CxGsHXUcvYtwNfpJv11zKINX91Zp8ABn9iPKO/WWQc2D4kuJv+RnfA@lists.infradead.org X-Gm-Message-State: AOJu0Yxg5uT+oxSKxqigzjuvZbMDNPR8hHrb5adTjZIvTvt/0R+fomeg hvgwqH5zU1z/u4pEQEWSYBeAzHlLmsQ/KirGSw/RzVbtsGudd094 X-Google-Smtp-Source: AGHT+IHZdg2jhk2e+Cn4R32SMBMGp+lA/vyCWsLnw2owXMmyeWM65kMhdSp1Pkri3UzB+6nV3OV+IQ== X-Received: by 2002:a17:907:8692:b0:a8d:44a5:1c2f with SMTP id a640c23a62f3a-a93c48f089bmr2181666b.6.1727366925244; Thu, 26 Sep 2024 09:08:45 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-6d88-4cd9-a9d4-f267.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:6d88:4cd9:a9d4:f267]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27c70d3sm13947966b.78.2024.09.26.09.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 09:08:43 -0700 (PDT) From: Javier Carrasco Date: Thu, 26 Sep 2024 18:08:38 +0200 Subject: [PATCH 2/4] iio: adc: qcom-spmi-vadc: use scoped device_for_each_child_node() MIME-Version: 1.0 Message-Id: <20240926-iio_device_for_each_child_node_scoped-v1-2-64ca8a424578@gmail.com> References: <20240926-iio_device_for_each_child_node_scoped-v1-0-64ca8a424578@gmail.com> In-Reply-To: <20240926-iio_device_for_each_child_node_scoped-v1-0-64ca8a424578@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Michael Hennerich Cc: linux-arm-msm@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727366918; l=1374; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=EJRXbPr61KxXV+wd3zzOVNML9/DOwfwUtS+ORGYy5xE=; b=/f3X+kN5zg9IByr0xsPHywl8fBIPhkGkWyTcEpKXic1JID9p1QUtQZw+Rxv8rHnGNjltXPBXJ CEaXlT1j7D2CSGsPT/HYk1mzjnkj0PWoA3Ziq1lLMmt1Wlmh7WukNL8 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_090847_203896_A4F45860 X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error path. This prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/iio/adc/qcom-spmi-vadc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c index f5c6f1f27b2c..00a7f0982025 100644 --- a/drivers/iio/adc/qcom-spmi-vadc.c +++ b/drivers/iio/adc/qcom-spmi-vadc.c @@ -754,7 +754,6 @@ static int vadc_get_fw_data(struct vadc_priv *vadc) const struct vadc_channels *vadc_chan; struct iio_chan_spec *iio_chan; struct vadc_channel_prop prop; - struct fwnode_handle *child; unsigned int index = 0; int ret; @@ -774,12 +773,10 @@ static int vadc_get_fw_data(struct vadc_priv *vadc) iio_chan = vadc->iio_chans; - device_for_each_child_node(vadc->dev, child) { + device_for_each_child_node_scoped(vadc->dev, child) { ret = vadc_get_fw_channel_data(vadc->dev, &prop, child); - if (ret) { - fwnode_handle_put(child); + if (ret) return ret; - } prop.scale_fn_type = vadc_chans[prop.channel].scale_fn_type; vadc->chan_props[index] = prop;