From patchwork Tue Oct 27 13:49:40 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: 307192 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=ham 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 017C4C55178 for ; Tue, 27 Oct 2020 17:14:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABE5420809 for ; Tue, 27 Oct 2020 17:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603818875; bh=BNu0jh3EbP6s15C2IyS+cuTmVxdex4iDTXQGZGZUJUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0/1lz+dNGKOX+9fNOxGXaFHXMQCHPproQOACQ2TVLifswmwpanGdjsDnuuH3Oulzi m4KL0ELPl7o1gxQJyg3zhJXPMQCTCswYAIKQ973IYb6+LwXeOToJKceEM+Ndd+WWlB oELpVkINiY+zuuCdKHatjo0b9Slto2zLFrTWzTmQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1817207AbgJ0ROe (ORCPT ); Tue, 27 Oct 2020 13:14:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:59960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773105AbgJ0O6e (ORCPT ); Tue, 27 Oct 2020 10:58:34 -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 3374C20714; Tue, 27 Oct 2020 14:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810713; bh=BNu0jh3EbP6s15C2IyS+cuTmVxdex4iDTXQGZGZUJUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AYHevJwrEI8YRCHUe8w/t0uludCJsgDuT5FynhjOO4PVfLo2Hu3nd9sG/EMo6u7ad zWmFAjUN0Bv0ObSql+m5cIC0ELufbv0GSQAH/y0cjUqM954ho1mL7+npHOGorzRs+2 D2NhlB9gWOtloCSKy5HzYLSaGN1N0yBqq00bKAOY= 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.8 237/633] nvmem: core: fix missing of_node_put() in of_nvmem_device_get() Date: Tue, 27 Oct 2020 14:49:40 +0100 Message-Id: <20201027135533.797327527@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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 927eb5f6003f0..394e75dede725 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -823,6 +823,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) @@ -832,7 +833,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