Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp250834ybi; Wed, 29 May 2019 20:39:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCc2Cg5bqx1oxM2q1GsQhMT/StG/aiPphr18/zs7Y0Q10UZSKYOHvjjcIewVU4ZjwsNIZn X-Received: by 2002:a62:ee05:: with SMTP id e5mr1488457pfi.117.1559187579526; Wed, 29 May 2019 20:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187579; cv=none; d=google.com; s=arc-20160816; b=0Owseo6dAWiJFStvUlc/zr9aHPwAtZhch/DtcQXTiKYFWF64K1QHGexN9tjvpYmP5H nAObitMosuOYAGCo/9ynwTfcdHlOfO2ssvdFtvEbk3ITTRga1Et2pdgFiQCublwaRtIP ESMlxqDMisJuoZkAtQNcy0ogAgYWe9xPkhtH+08ZRn2BsPGrJzeC10DpVERpNxCT2Lh7 pOt/pCrj3fEz2nQmFZPAVgKr/fLeRrcBFbmEjeKUjcC3CqDizcdcor7FNG5ZIs0BJeVR hyDhhtid+EnhOqxQ8gkbu5HUlEXqfF8f/DokKBSVNHdg8rzhkRsnOZ0XecvwTCuP619z iPHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tMX1gK4sA/bi0841FL2cnGPUtw3j2vnEIsRpGq0Qw3A=; b=KpSWRq7V10LZHePDM8szuR8T6chzUfjefPNsEN3+cAEN0Bf0zlGeCkAweyn4MvGtxU s0EsOwmnLECKVlmA9CcNWDytRN7hCeB9SEWTaGSRHW2AvoIe5yPQV1U2fx1aQwS83xPS mLkcQMRLyGCcqaI4lj4MTJfWmSlj/VhHg/XtL+0nJAZ2rWhDR5rF9TvKpGRotOdkXf3M ylA1reMzIGPVns5XLolc1x2wwBS9U5ZpsyzekXhfasfyRV9g/HTevkIPksjkDUk+DBw6 Nwm4gWFBrHlyS7hqb/aZtrEMIc9EpArbnWLafE6R4PVV0bsLObZVFyKm9LWRdGhmWlmA 8CfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="1lTsoB/B"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si1627978pjk.66.2019.05.29.20.39.22; Wed, 29 May 2019 20:39:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="1lTsoB/B"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733004AbfE3DXE (ORCPT + 99 others); Wed, 29 May 2019 23:23:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:45326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730972AbfE3DRN (ORCPT ); Wed, 29 May 2019 23:17:13 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 7035124692; Thu, 30 May 2019 03:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186233; bh=72OU6/E9r+R3S7kGaNCtbOCaNYutmfAb+PEzWF0SBPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1lTsoB/B32VQbatIQ88quU6ft530uisTiWNcB0mjtaPYBmWzVAedfw9UE3f2CSCbo sVN67yJMVlWsyh5uN4sxgf5i8ZyQ0uYwmW+IESk3iJYADQPKa/SM7BCrZ4B+wO1Z73 vQsm6OvhpsHykgKtHASvYTfF0bNlI/TY/NKPOOvY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jordan Crouse , Mamta Shukla , Thomas Zimmermann , Sharat Masetty , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Rob Clark , Sasha Levin Subject: [PATCH 4.19 140/276] drm/msm: a5xx: fix possible object reference leak Date: Wed, 29 May 2019 20:04:58 -0700 Message-Id: <20190530030534.446007552@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6cd5235c3135ea84b32469ea51b2aae384eda8af ] The call to of_get_child_by_name returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: drivers/gpu/drm/msm/adreno/a5xx_gpu.c:57:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function. drivers/gpu/drm/msm/adreno/a5xx_gpu.c:66:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function. drivers/gpu/drm/msm/adreno/a5xx_gpu.c:118:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 47, but without a corresponding object release within this function. drivers/gpu/drm/msm/adreno/a5xx_gpu.c:57:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function. drivers/gpu/drm/msm/adreno/a5xx_gpu.c:66:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function. drivers/gpu/drm/msm/adreno/a5xx_gpu.c:118:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 51, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Rob Clark Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: Jordan Crouse Cc: Mamta Shukla Cc: Thomas Zimmermann Cc: Sharat Masetty Cc: linux-arm-msm@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org (open list) Reviewed-by: Jordan Crouse Signed-off-by: Rob Clark Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index ab1d9308c3114..ba6f3c14495c0 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -35,7 +35,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname) { struct device *dev = &gpu->pdev->dev; const struct firmware *fw; - struct device_node *np; + struct device_node *np, *mem_np; struct resource r; phys_addr_t mem_phys; ssize_t mem_size; @@ -49,11 +49,13 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname) if (!np) return -ENODEV; - np = of_parse_phandle(np, "memory-region", 0); - if (!np) + mem_np = of_parse_phandle(np, "memory-region", 0); + of_node_put(np); + if (!mem_np) return -EINVAL; - ret = of_address_to_resource(np, 0, &r); + ret = of_address_to_resource(mem_np, 0, &r); + of_node_put(mem_np); if (ret) return ret; -- 2.20.1