From patchwork Tue Oct 27 13:48:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 289687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4D7CC64E7D for ; Tue, 27 Oct 2020 15:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73ADD223B0 for ; Tue, 27 Oct 2020 15:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813407; bh=v73Ta+ScJRWCFopas3K9azkdlpQ0DyatyfvApVT089E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=N9HpD73nDAEDWMdENc5hShq5I+S2jNMfzEfuo/PtZYRcJQe4m4UEqDFJQwHmC+7VJ nxBY+EIksC+EVBhTpB1efGrnT7GVJXVA7p3X1yGG0ZPfbxDrwJE9vsDg3uLcrcp+Fb oRNPnpL5wy+MuNz+K6OcPbgc8JL4vrDPNLAyZPp0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1799567AbgJ0PcL (ORCPT ); Tue, 27 Oct 2020 11:32:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:49244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1799561AbgJ0PcK (ORCPT ); Tue, 27 Oct 2020 11:32:10 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4320920728; Tue, 27 Oct 2020 15:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812729; bh=v73Ta+ScJRWCFopas3K9azkdlpQ0DyatyfvApVT089E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jmrgcyi24Ct87iwrPK1d/Gep22yRTbN/i4Qhdw9mIL/b87F4HqsozY1GGfYpcGU1R 33KzBzirU1wIduxPE9gxDp/LJxubyJaQSBgZ5CJYCsnRLqKkRYbpd5G6IldXK+Rr8n ckAZTHwVTTjBUuux8sTou+W5TLqn/Dz2vpCD9KfE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vadym Kochan , Srinivas Kandagatla , Sasha Levin Subject: [PATCH 5.9 280/757] nvmem: core: fix missing of_node_put() in of_nvmem_device_get() Date: Tue, 27 Oct 2020 14:48:50 +0100 Message-Id: <20201027135503.718376550@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vadym Kochan [ Upstream commit b1c194dcdb1425fa59eec61ab927cfff33096149 ] of_parse_phandle() returns device_node with incremented ref count which needs to be decremented by of_node_put() when device_node is not used. Fixes: e2a5402ec7c6 ("nvmem: Add nvmem_device based consumer apis.") Signed-off-by: Vadym Kochan Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20200917134437.16637-5-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/nvmem/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 6cd3edb2eaf65..204a515d8bc5d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -835,6 +835,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id) { struct device_node *nvmem_np; + struct nvmem_device *nvmem; int index = 0; if (id) @@ -844,7 +845,9 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id) if (!nvmem_np) return ERR_PTR(-ENOENT); - return __nvmem_device_get(nvmem_np, device_match_of_node); + nvmem = __nvmem_device_get(nvmem_np, device_match_of_node); + of_node_put(nvmem_np); + return nvmem; } EXPORT_SYMBOL_GPL(of_nvmem_device_get); #endif