Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp648303pxv; Thu, 15 Jul 2021 12:25:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZT67TykgoS+oY3mR4eaLhuAElDaK/MOLTLe/9iG8y70YId0PxT6SeEHOg+ZUaHGDGapH7 X-Received: by 2002:a17:906:eb99:: with SMTP id mh25mr7205769ejb.330.1626377117172; Thu, 15 Jul 2021 12:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377117; cv=none; d=google.com; s=arc-20160816; b=YQAwSAqhbt6xiPZLMA5HGCndGp5hfCcDyJxW4nixLmrVDqG5Be2NCkDIIaBkFLnell DTMunM2/SxwYd5mu+HC+cW+zgPLEw74JQ36C5EEh2htUPqPBmDKret9WrsnOKYSLj+oL GNdzUy07ITF3eZU7lZDYYcdUY3O3KGx9dt1rPnCj0eRPFM/4SpWpbbcY2uhvnud7fSkK x/gYcxHsyTMwNuZk/P73qP5fjV8Nm3CdzBtuuYxnd8BgeNRUMynHlqSUg8UmVHOPJQDe N2tXnHFq43L07jB202eny2tadW4VwD8d2sP1uAsk01bVYqn5l2mFy0BVtmD1eFedOZtv IyxA== 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=KS+dx20w28Ik0g+O3AgGvztZUJGvAy7lyA8QjoEok7oy023gMYIJrvWjLVb9KoJvEx jkFArXfuMvVoy1Qsj1oezdns12qY331U9qCnRXiSAAinTNCov4AVgtjCykTmlz7azBq+ Zj8Z5ycyfGOyFq8I2VpOUmeMZTAwsRkjPQl70lThlL9ULtIpyb3SDZk84oc+Cth/hfg5 A+eSHQNiWj1ZRcDuRyuMUgh9BZkDJ2+YmUFrThaJoSXUsKxqwag8IPNCrOD5yAxxK1eO 1j0OdhP5JUxtfJeJt79Q0RGcg7pCFcXuhvXSXSBnZoh0GYURDiNOiKdaAD4Evua9W73+ +x2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qZd0vqCs; 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 j25si8458421edj.432.2021.07.15.12.24.54; Thu, 15 Jul 2021 12:25:17 -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=qZd0vqCs; 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 S1343622AbhGOTYe (ORCPT + 99 others); Thu, 15 Jul 2021 15:24:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:46406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240943AbhGOTHt (ORCPT ); Thu, 15 Jul 2021 15:07:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E3E50613DC; Thu, 15 Jul 2021 19:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375820; bh=XqrB24X1ye5kgsWGM7gXL+a8soN9g30UbzZFfOELc3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZd0vqCs3qMFtIvdgoTQRQC/qQxnYLwXESjoilIMwNs/6GSXqBcz6cSBzI8Y/or+C LkLKLiD2uvS/bexPXkqfBJt8WOu+nDwBJAWLP44W6WwGKQ+FPcemmyqv9SRt4KK2Rw ABwnV7RqUrDqbGxD8GX6pPdvPW7hkxbGBOHUuzeI= 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.12 203/242] nvmem: core: add a missing of_node_put Date: Thu, 15 Jul 2021 20:39:25 +0200 Message-Id: <20210715182629.017718823@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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); }