Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp660857pxv; Thu, 15 Jul 2021 12:46:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyu/7NkHDEIAAXERw4jbVLpvRA7oh7JpJi+iIYMnoABwlYYltFvtlaNqd2Tzdr9xfphGJI X-Received: by 2002:a17:906:544f:: with SMTP id d15mr7232896ejp.520.1626378415542; Thu, 15 Jul 2021 12:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378415; cv=none; d=google.com; s=arc-20160816; b=Lo2ZapdD5KMATshdqjGyZiwnto8evmRi0h+qcY1GOc17HZ5kvfU2XeMRGAyttoRw8G XIkzhWnToCRKASWOO+/sLNarPxZ6ytDrP8l6Fe5Eon3dlTfANuBC8iqBRNUYxVhA6sYp 7HDkwKoEEad1Vh6Yi0YsN/FVXGnay+oeOKxVxkslVw+QKKiLXOKLOMG+1gC2yz0WsdrK skQl8qrqD+cNy9GCSkcLGGoZJ/ab7P61sO4AT217yNJug8RwCeI2T94ufwi8GJ5eKNop W5/7dHwjOzmVKT80q6mwILq2hLik2s0FhEKETeHFy8gVhFTSIIHu4zhQdi+mw3A7I14O VQeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xy5yWolDdVdTqofQOsCKAviYEORqB9jOjEmSBjOAU3M=; b=uNaquFilfOn1EW3zzB5FDCkGJh74EfvSTBOLw9DcbY4GUqYOyY4R1E6MW1ADCQS3Xg naCjafK+1CEJMILbUJimHvxTw1POct0qDo5sh4vuSNnD142lQfW1+7QR8X3qnS1lv5Tz SRggiArQZxsUwQzZnqPMdXG0A/Xe9tNnQz3ziNogk/9bBJNCnkC26iyjN9ipRoXh314N yAFkKfmjO4RviETaKeDCgOLTc6yK0KD1pyReLzm8JopjpPJQUWajpbykB7e+kqYpJLEK OCUi/XZIPYx8j06v5k/24dMSCRhLE7GgQpTCaxLrHF08XkZL3PRHCOmDXc2PGxhqU0XP 15kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hbgV2SD/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx16si8013373edb.96.2021.07.15.12.46.32; Thu, 15 Jul 2021 12:46:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hbgV2SD/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245726AbhGOTqK (ORCPT + 99 others); Thu, 15 Jul 2021 15:46:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:51020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244045AbhGOTP6 (ORCPT ); Thu, 15 Jul 2021 15:15:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6584B613C4; Thu, 15 Jul 2021 19:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376334; bh=XqrB24X1ye5kgsWGM7gXL+a8soN9g30UbzZFfOELc3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hbgV2SD/iCAtpqpO7rJ14GL8l3/Aav2Dq8S2+37JnqEFZ538T3qmpqpQpG0ME1FLF SzgTfvdC9mufZydDJpHW15T0UflGqoZAL0B7m5J3kUpw7QSvqNrBLrX45V7aDssy6H Q32aCLxkWPxFGYJHhVD53+RZKanp8RVcqBjROz6k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Srinivas Kandagatla Subject: [PATCH 5.13 227/266] nvmem: core: add a missing of_node_put Date: Thu, 15 Jul 2021 20:39:42 +0200 Message-Id: <20210715182649.225195642@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET commit 63879e2964bceee2aa5bbe8b99ea58bba28bb64f upstream. 'for_each_child_of_node' performs an of_node_get on each iteration, so a return from the middle of the loop requires an of_node_put. Fixes: e888d445ac33 ("nvmem: resolve cells from DT at registration time") Cc: Signed-off-by: Christophe JAILLET Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20210611102321.11509-1-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/nvmem/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -686,15 +686,17 @@ static int nvmem_add_cells_from_of(struc continue; if (len < 2 * sizeof(u32)) { dev_err(dev, "nvmem: invalid reg on %pOF\n", child); + of_node_put(child); return -EINVAL; } cell = kzalloc(sizeof(*cell), GFP_KERNEL); - if (!cell) + if (!cell) { + of_node_put(child); return -ENOMEM; + } cell->nvmem = nvmem; - cell->np = of_node_get(child); cell->offset = be32_to_cpup(addr++); cell->bytes = be32_to_cpup(addr); cell->name = kasprintf(GFP_KERNEL, "%pOFn", child); @@ -715,11 +717,12 @@ static int nvmem_add_cells_from_of(struc cell->name, nvmem->stride); /* Cells already added will be freed later. */ kfree_const(cell->name); - of_node_put(cell->np); kfree(cell); + of_node_put(child); return -EINVAL; } + cell->np = of_node_get(child); nvmem_cell_add(cell); }