Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp454851pxj; Fri, 11 Jun 2021 03:27:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKCKi2xw1lxXmaPJnhnXxKRPtuEYS7Ps98meGLkFQCkiioGn0KRb2WJ9MWWfIQHznTmIlQ X-Received: by 2002:a05:6402:74e:: with SMTP id p14mr2925552edy.17.1623407235799; Fri, 11 Jun 2021 03:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623407235; cv=none; d=google.com; s=arc-20160816; b=gfrbPeiW5XNB3vuTWxGox8J5EgRQnjXScj+PWc4ASni+d1AIBNFJIP/ax+ymMCnZlY Unn32dDdbNY65qORJeo/1UPvhnLXupHEWMPoZwTwhgKrIbysAB43F2b79x3IknCSX0hS nKVb1uJ0FUFqjKX5V2NhIEK8PBNh6MVZCrbWLDw3IRA6TI/IawUzkMPwDriyZlxKr6Oc gLNQTRaOn+fGZ3NXDlI42zzrbdQaPnIEBefA1mq2n19N3Ah1IRIp6b1UJSdC+eSxjKRd dfyYrVmwqALWbWNKGa9OjLDIFkwRTlOP4bOH2Ml4005OsPmaUI/3Ejfe9eWkiUsQtRQd uMdA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=2f7/TFgLVrG5lfOiI4zi8HzRCiY/70uX27quxfvnzbY=; b=wWZ59phSEodyV6MrA61sFZm/eeEJkeSKTvm+xlof5HGMi1yF9Y9P9dBmb6lCRdAEqE Q8GMpG5ylnPCb7ViwTa8CHsRCigTab0LYtOqUtOK3E9OXK3AkrCHJqIAELooNTDNiYIe hNUJGzHUs3Oqqh7GmrxNKQ9fdgD1Hl/0jNuX6LHfKoumPXnke2ZTXx+vgEjm+7wIYrFj uMAa5SZyj6A+ylEiGMZVmiYjN1qB/rLZQiamdUTlLvEUh1PYy8l7MFqkrGpWjqLkO9k8 cAHbeO0V9LWBcaqE3ysLeVLy/Y15XGhZtyvkJo2aXEjzFkveYMGXrG1MQkq37eKGHyUw GPMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jKGxIQHd; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si4883700ejk.101.2021.06.11.03.26.53; Fri, 11 Jun 2021 03:27:15 -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=@linaro.org header.s=google header.b=jKGxIQHd; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbhFKKZl (ORCPT + 99 others); Fri, 11 Jun 2021 06:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbhFKKZl (ORCPT ); Fri, 11 Jun 2021 06:25:41 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1231FC061574 for ; Fri, 11 Jun 2021 03:23:29 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id c9so5470701wrt.5 for ; Fri, 11 Jun 2021 03:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2f7/TFgLVrG5lfOiI4zi8HzRCiY/70uX27quxfvnzbY=; b=jKGxIQHdD6gjIrzQmopPo2aSyn3PhYLolsFqRZP4AnTV1WTgXzPoqql6wnFSyjQgOW popRktZsPNNUJEWKc45RrZ+3bgZKqK3Q42YExWMGLoLi4woqg2eRKMmwsTFlCjXpbdcf CbaVOEzAh7z+36/OnnZ4JJHsZywSCelJz/VZXkaDVGXfByvg8p/OPJP1duYohYQTV4DL bUzL4S9g6bgVSvDn26LNk38/v+RNfiWozQZSPHUmYyCvE9UJmbtF8S6KF1LrJrVkLH8f XkrXeH+7/tVvbSOTx0teONFsJ+608OB4C/FnCnmbSDW+76Ko0nVhzam+SLwmp08sRSd+ xPBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2f7/TFgLVrG5lfOiI4zi8HzRCiY/70uX27quxfvnzbY=; b=XExlA/5J/MJ6SfC+m/wy62/39KhvX1RLLWJD6ycnXXEoTz9Ov204j2+BttsDhm1fDO g7Tk0uUo3Q2NuDS1HZir/w3Ekx3JPqGU656pXHfeN82lWqSXUlw0WilC29ac36tOrElM 9Uxz9zfaukMJA0PdJtcSJmdHiFVpDVSAX1qZc11V0cwBhmRDMHnIIgbqfxSSoEnqXMLC kNDia88jYsohr2wNcmprsDkaU1v35z4r1aV5dbsHU1j7+UQ/GVKFPT3VdO+mBBIGIQpe TivZ3moT8HXvojCh6mi6+059H40gAee7psRkhUwuvpp7p/sXnW3bF9ldALrRnB0W3Fgx X8vQ== X-Gm-Message-State: AOAM531Qxeh85mp9ia9vOMGsF4I4h0vBSVK3K1HVVvB+EWNAAsk3GcO2 GwwzWwU2/Ejd5xMRhLAjZiGqfA== X-Received: by 2002:a5d:47c3:: with SMTP id o3mr3305518wrc.122.1623407007638; Fri, 11 Jun 2021 03:23:27 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id q20sm8317234wrf.45.2021.06.11.03.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 03:23:27 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Christophe JAILLET , stable@vger.kernel.org, Srinivas Kandagatla Subject: [RESEND PATCH] nvmem: core: add a missing of_node_put Date: Fri, 11 Jun 2021 11:23:21 +0100 Message-Id: <20210611102321.11509-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET '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 --- Hi Greg, Resending just this one with cc stable as rest of nvmem series are already applied. thanks, srini drivers/nvmem/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index b3c28a2d4c10..4868aa876e1b 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -686,15 +686,17 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) 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(struct nvmem_device *nvmem) 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); } -- 2.21.0