Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp530080pxx; Wed, 28 Oct 2020 10:23:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzssmWleaXZHQdrnTQwGGH20/LHDJk2AU4B0wDhBVlJ2rXJU0+kbwIfUm1KsdnTCU7ODUFy X-Received: by 2002:a50:e40c:: with SMTP id d12mr8731047edm.35.1603905803312; Wed, 28 Oct 2020 10:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603905803; cv=none; d=google.com; s=arc-20160816; b=QkOWt2uIVST2FP/jQ4+2Wgx89QMlFBM58TAxVI/mRlHL6yU8a1aAgJMMt8lrxCP1Gg ov/LFQhwmUrv9DLsYY5mqVqcxUW4Sjx1vJnTrNBZlLYeK4/qIt4PpbEEDIZfzuv2AmWK TNxFszVwfE5RmMxRrldxsoEjaex/nL7pDsSiUx41pcJ5/AQ9neiHHs6BtNLxz63gA5UE VsYu4eSgIZY97yv+Q+s/VIW416Hsv0g5KXCAaePYZDoCYTRyCG5aatNSZ5ftvDkY00Dh TRCvPUkm04JAix/nQnj/OKBphIAL555F5BdzPqGT2/8fKjwWxl4IEUTHr4Q+SWTOW6k7 S+ew== 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=9XAJl/YNQOVStNKlHxvTu0G0ICd3I07zCr2RAxal4OI=; b=NCCGqSkx6jQ/e26wJgRQVGzdeUN45AQjiley49EQr3lEwHtPHZ0emUYGphCPpR5GyI RnnEzmevH4DbUTCOzuMDPvl/oFfIPLVKXtd6JAcuDNjoHq0Bsqw+M3TjzzXRkF7D2xhN akGfl+o4aJYaWs0r7wv1DlKR3FPphFsJarcfvAEOzHidUXF7tBea5aDrLG3iWyj70EjQ +YfsSmRD1UF2HmxcQSUMvFdBq8pkvT6fPLq5mDOwA/AjjhoJe/jUuVMO3NV2MBQU5TD6 PRnSgUS11Pbb0IYqs8yLq5zO/06fH9x5jymYqdXLYzuxIiNWj7FVsn05cRAZuk5x4Bm/ WuoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tEKpTfRa; 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=fail (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 w11si3696538ejq.533.2020.10.28.10.22.59; Wed, 28 Oct 2020 10:23:23 -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=@kernel.org header.s=default header.b=tEKpTfRa; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1821191AbgJ0RlK (ORCPT + 99 others); Tue, 27 Oct 2020 13:41:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:59686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2902332AbgJ0Ocq (ORCPT ); Tue, 27 Oct 2020 10:32:46 -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 7405620719; Tue, 27 Oct 2020 14:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809166; bh=VwfiyVImG4KNBSklL8nDqKwntMq1xxLWJNG+hRC/SFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEKpTfRaRUCKbMoGnudTehWoUf793i0+ZapOh/m1XcH0b9OB2KAWsnFZNlc/gIg3a sj2dKuNaEJdAxLj134LCzIJeogzVRBUj3n5AxlXjv6dqOeFHCFbfrWTPrg/XbyW6B3 qKg6sihRZVXJ2+dIq5Tus0omEAsxWu6jKpM9P7UU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Pinchart , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 082/408] media: rcar_drif: Fix fwnode reference leak when parsing DT Date: Tue, 27 Oct 2020 14:50:20 +0100 Message-Id: <20201027135458.871522436@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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: Laurent Pinchart [ Upstream commit cdd4f7824994c9254acc6e415750529ea2d2cfe0 ] The fwnode reference corresponding to the endpoint is leaked in an error path of the rcar_drif_parse_subdevs() function. Fix it, and reorganize fwnode reference handling in the function to release references early, simplifying error paths. Signed-off-by: Laurent Pinchart Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/rcar_drif.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c index 0f267a237b424..208ff260b0c10 100644 --- a/drivers/media/platform/rcar_drif.c +++ b/drivers/media/platform/rcar_drif.c @@ -1223,28 +1223,22 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr) if (!ep) return 0; + /* Get the endpoint properties */ + rcar_drif_get_ep_properties(sdr, ep); + fwnode = fwnode_graph_get_remote_port_parent(ep); + fwnode_handle_put(ep); if (!fwnode) { dev_warn(sdr->dev, "bad remote port parent\n"); - fwnode_handle_put(ep); return -EINVAL; } sdr->ep.asd.match.fwnode = fwnode; sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE; ret = v4l2_async_notifier_add_subdev(notifier, &sdr->ep.asd); - if (ret) { - fwnode_handle_put(fwnode); - return ret; - } - - /* Get the endpoint properties */ - rcar_drif_get_ep_properties(sdr, ep); - fwnode_handle_put(fwnode); - fwnode_handle_put(ep); - return 0; + return ret; } /* Check if the given device is the primary bond */ -- 2.25.1