From patchwork Thu Sep 26 16:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13813504 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 DC944CDE020 for ; Thu, 26 Sep 2024 16:14:10 +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=GfSfRbf6HpAPUG9dd1ayagyvrPMaeTlKhJpm5dY0lEg=; b=TmhBoBKSHyAaF2Cucjx8PdqEk5 64S6U/zDajksNusUJ/pE6NzilDrgpRgO4VggAA+PKh/I5khyLzktXfi+h9mfAp1B7WHCUvLIwORg4 ZPHcQ+jK17q1hctv9IZRIDfLgvG8220YigrL7Ui3O7eileLXlUl3aVBYeQRYiv+Rz+SKxKq7CKP4i otFdUI/W1UygV2LMBHIjq6r9CCHgGZx50jHg+ghOvQ4kZueVbrlYs+cix1opjjj5eFCFgzgU+nPCt 47bvgCKIJMSYp7xE1f2V12UcTP+DiH0VTj0iWqzJ3hL1Qc+47+qDyHt+9fLVok+E58CqS3avfVgA5 Wh5WAISQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1str7y-00000008rKf-1boe; Thu, 26 Sep 2024 16:14:02 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1str2y-00000008qO9-1hmk for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 16:08:53 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a8d6ac24a3bso222569066b.1 for ; Thu, 26 Sep 2024 09:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366930; x=1727971730; 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=GfSfRbf6HpAPUG9dd1ayagyvrPMaeTlKhJpm5dY0lEg=; b=gdewAiYjj4ctAM3PtNId3CdxYJQQtARd3qe3jaU4pqsShF5rgg+k9bph4uMKHg97Pp II+5UErbBzbBhneCmw5Im14LNHL4Hv+ayUyXD2iu8BiHzdJu4reib+fWzqyHYWXIcExT k95EouZ7G/By5eVBWXTu2yCctEfgktMseBHV0Cu8fFiDRyF9O6fzMo3vlXHXUW2SEIf5 Ktq0wI1txDqqKdfOCBCuG15bK3T5Zj5LCGmc4Rq32OYN0dyKK7yOi4XN/sdqPDYs4B7g imbkQzH8FRQEVTeG00DyOFzr91II//wVVQuWdPkg9X+C8xB4/A1LUn7/YZ0xMC0/rN8v lBTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727366930; x=1727971730; 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=GfSfRbf6HpAPUG9dd1ayagyvrPMaeTlKhJpm5dY0lEg=; b=JweEUNrs1HZw3mJQe4Bs09mtGjFqFvFZ6wECHxvV/bVIbfQcC5Pb1YyEAaD30PODcq Uhpy+ZXbcDOiAewdCTuJ4hVjx1pbH+n7Gpsh4QejiMzvegU89b6yeWOwVtqtvkqe6CCk qGnb1mkABVBbAKlmRRptvSU6z6gUBeZWouJexLK9z8cY5gPn++nlR3XCUV8UgIfhmgIb Px2WMXW2Wf88jIISV5oTDEWX9C1Q/DTW/zy++/LRUeSLp6WMx4ZHp2e0u780vriYBq+V yszlT9llLZz6PuZoFnmlW2PknKeAcNvfd0SN+4HebDrwLBCHT8TgoKZ9/FDjabvwXnSr vOkg== X-Forwarded-Encrypted: i=1; AJvYcCUv6V8sRrs/idmgSWYXwOpdhEqFdbrXz0ZJe1GFtcDC6ucqHBKshGwkez8QAR8HP7le6swfQNrGyUTht2hsoH0B@lists.infradead.org X-Gm-Message-State: AOJu0YyJuKQ5kqabeayJuof+bJkCBUuMeXGNC5zEgE7MhDCFo0hdSYbL Eq3xMLsSgSWfOfh53xovaLjZH+D4qzj8OUxXCL+b8f1tNZTnpLCx X-Google-Smtp-Source: AGHT+IEa8ZK99gytPYhlMMIfBCh2WLdWCb9VYkK2bIOBiKcxBkDWAAatz/BvNKwWyUydN132lAq7Sw== X-Received: by 2002:a17:907:d2e5:b0:a8d:5f69:c839 with SMTP id a640c23a62f3a-a93b15f92aamr392676866b.15.1727366930195; Thu, 26 Sep 2024 09:08:50 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 09:08:48 -0700 (PDT) From: Javier Carrasco Date: Thu, 26 Sep 2024 18:08:40 +0200 Subject: [PATCH 4/4] iio: adc: ad5755: use scoped device_for_each_child_node() MIME-Version: 1.0 Message-Id: <20240926-iio_device_for_each_child_node_scoped-v1-4-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=1682; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=xTmIMKWrAEJ2sxUaBzK8+gdHqeGN97Vi3rD2yxlm2m8=; b=PgLKXJGq2MweGHIGTLRvljlOM7oxtbS7Y8PJM25aEBf0vmjeCKYh8ES4/Km4e2w0Irtx2nvj1 ddQdkAH4KPBDo3JfVnrEyLrV2hVMi0/5mNJUuT+Hf4ES1FMXY9K209/ 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_090852_483053_84B8BD8B X-CRM114-Status: GOOD ( 14.24 ) 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, in this particular case dropping the jump to error_out as well. 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/dac/ad5755.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 0b24cb19ac9d..05e80b6ae2cc 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -699,7 +699,6 @@ static const struct ad5755_platform_data ad5755_default_pdata = { static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) { - struct fwnode_handle *pp; struct ad5755_platform_data *pdata; unsigned int tmp; unsigned int tmparray[3]; @@ -746,11 +745,12 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) } devnr = 0; - device_for_each_child_node(dev, pp) { + device_for_each_child_node_scoped(dev, pp) { if (devnr >= AD5755_NUM_CHANNELS) { dev_err(dev, "There are too many channels defined in DT\n"); - goto error_out; + devm_kfree(dev, pdata); + return NULL; } pdata->dac[devnr].mode = AD5755_MODE_CURRENT_4mA_20mA; @@ -800,11 +800,6 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) } return pdata; - - error_out: - fwnode_handle_put(pp); - devm_kfree(dev, pdata); - return NULL; } static int ad5755_probe(struct spi_device *spi)