Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp791489rwb; Mon, 26 Sep 2022 06:02:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7KHU2N3YIIMUcja9Z0zRIRnkN79KkFBx4zFWeDqNphjyHVfDgB1arXsceo1LvGXA0e05w/ X-Received: by 2002:aa7:c58a:0:b0:457:463d:c19d with SMTP id g10-20020aa7c58a000000b00457463dc19dmr5201391edq.323.1664197366518; Mon, 26 Sep 2022 06:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664197366; cv=none; d=google.com; s=arc-20160816; b=uZ7i1MiT1QuxFHO3Dy4ouzLduoHyrTfp8orZ4kFMeGv4i5dATSGy8xdjILhmnv+kPG OSfEaGd8yoIfu9u8MnscNeWWQymp2mKA0dSj6p4TiIG0gQeH84+lTjIboHxkFlvE2ZE0 F0ixQcyFAl+ilFJZCab/qLHcDymr8UND4jN2WlqZ/A1LGAky65tBuTJv/3XJevkN2Fy/ N9PiztXn1vTT45ZpFyetXQJcifuhxRARA12u6U3F7RmjtFltUBxL8as+prJr5Q5GqKFj Ls2I2Z+8uOEY2pJtbQPleIxAbaHSk/3V2zoj8zSjxf5LtDDZLczBvIM5mBTczzg84rHg 3rrA== 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=1UUeKqSeYE9SIRLamEbMzpEoP3Bt4TjaxwJhLK9qWk4=; b=wgnv5V6rWwnGqwik143X+WKWF48ezzkL14pblyWcWimclyDK1Jn6WHW832AKKekkP3 AdHWjmHwyBsClld7EVzLuQQMHy92o1lWS+T7RzKe+TEXtKpZf7FwWKW+RjA+SOkZvfea LQcEWnZ2Mc+ZDG8Y+x1Hh7m87JsirvjYy2JMKwXp8caKM6xj0IfDU2lDGGclCy68Eudx WQgKRMg8meMc78hqaeJOQdrVILBOqJ+pZFRoQrizqsM3J2gsCyZSXluM0OT7wfFenrgL 7VoLuUOfT3pgz2DHVuH9rT12RnfUFlZcBaFpcMapnAyRBqsZ+iz6in8XXPN2/2p3+uDq p+0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KbcXclna; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wt1-20020a170906ee8100b0073d866e5d4dsi18311611ejb.98.2022.09.26.06.02.19; Mon, 26 Sep 2022 06:02:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KbcXclna; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238572AbiIZLqI (ORCPT + 99 others); Mon, 26 Sep 2022 07:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238379AbiIZLnV (ORCPT ); Mon, 26 Sep 2022 07:43:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 370015508B; Mon, 26 Sep 2022 03:46:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DDAC260B55; Mon, 26 Sep 2022 10:45:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB2B4C433C1; Mon, 26 Sep 2022 10:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189122; bh=df8/eRBlP1PeK6BKFY7uxt1LSUL6QU9ec6A+wvlYhMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KbcXclnajl1aLjA/iPFYuHFqPs96nRZ0TaxXvwM4NVDTpxYxuellkUGZSb06FEDL8 g9VUYK7PIVFNYD3m78nHmq9lAEOcqk2g7gIaVJj/pBNZlmZXhanOua7lW/Tc5abAc5 7538RfoZdqR71SJ5MbYlVxFUurPvHkHuFizMsJ2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Peter Ujfalusi , Vinod Koul , Sasha Levin Subject: [PATCH 5.19 081/207] dmaengine: ti: k3-udma-private: Fix refcount leak bug in of_xudma_dev_get() Date: Mon, 26 Sep 2022 12:11:10 +0200 Message-Id: <20220926100810.203362643@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liang He [ Upstream commit f9fdb0b86f087c2b7f6c6168dd0985a3c1eda87e ] We should call of_node_put() for the reference returned by of_parse_phandle() in fail path or when it is not used anymore. Here we only need to move the of_node_put() before the check. Fixes: d70241913413 ("dmaengine: ti: k3-udma: Add glue layer for non DMAengine users") Signed-off-by: Liang He Acked-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20220720073234.1255474-1-windhl@126.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/ti/k3-udma-private.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/dma/ti/k3-udma-private.c b/drivers/dma/ti/k3-udma-private.c index d4f1e4e9603a..85e00701473c 100644 --- a/drivers/dma/ti/k3-udma-private.c +++ b/drivers/dma/ti/k3-udma-private.c @@ -31,14 +31,14 @@ struct udma_dev *of_xudma_dev_get(struct device_node *np, const char *property) } pdev = of_find_device_by_node(udma_node); + if (np != udma_node) + of_node_put(udma_node); + if (!pdev) { pr_debug("UDMA device not found\n"); return ERR_PTR(-EPROBE_DEFER); } - if (np != udma_node) - of_node_put(udma_node); - ud = platform_get_drvdata(pdev); if (!ud) { pr_debug("UDMA has not been probed\n"); -- 2.35.1