From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC592356BA for ; Fri, 23 Jan 2026 18:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769192609; cv=none; b=Kkyo1IH6WW+ozSxkd6OSM8pIeC8//npYBtyGz887d/HsH4122QqhI2zmgNC/CMGaoPbaYWDT6z4yrkfItjSrzYyjNreGDMiLPQNKG9j/rmOWAczaVEoy8mKAf/UlBGLTfaiCHUey5OeB03KdREkls+kKYCbxMgxRotL/VAgYNrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769192609; c=relaxed/simple; bh=8cdCqM5vyc0qfvH/GXDQghnWpIPo65ja1UaVzd6M044=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NYUxQI8gpf9wSxgMr9qgcefCLNgTTdzIpyKEHqexCGFUBKSmWGA/RQ6B8p6QH+uzdMKa5JUIyBs7CXivq7P7pqm9d4UTxteuurETqPKdKsKGwhqaFMimbQvdPscb40oye+lQZ5n6pCsW/Kgp30JSIBE64lHzjlG4p32NswF3AjY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=kQMVoNlx; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ODO2g54/; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="kQMVoNlx"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ODO2g54/" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60NHr6T8723019 for ; Fri, 23 Jan 2026 18:23:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= JcQRaSYmswErFvxepDWiHW0BBlPKFj7UEtuNsulcBmI=; b=kQMVoNlx7hAtO97V 8MA9n+nrQquFDk6KQKj2rG84pzAcoNkt6XYf3wka/T7fD5IL4w7WMg97ubWNqlVS +tbAexM027MM0yaTBNGO+z2XyEmWl3HGQ2iuBHyEI88ZayI3UPHkucR3ZbfJ7VcP 72XKw9Z0zHKwrwPH7sXXGifAK122hDy93PQoN2+tawwgl9sFgVdY32KoHcgu2zAI eWHL/IAXkURS4w6ROPjk2YSP408u+n2vBEBkj8DlZgiheerzY8X8j3SV2wBXR8KC 1j21tkxgEuZnrWYKfN4aGbvEb41wqBIqMAx5yM+3r4C8Phh2tpVVmtxOR4L3BIKR yPnbMw== Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bv069k4hp-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 23 Jan 2026 18:23:27 +0000 (GMT) Received: by mail-vs1-f69.google.com with SMTP id ada2fe7eead31-5f52fa0d3cbso2058075137.1 for ; Fri, 23 Jan 2026 10:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1769192606; x=1769797406; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=JcQRaSYmswErFvxepDWiHW0BBlPKFj7UEtuNsulcBmI=; b=ODO2g54/TBq9SvA5csdspXhvo5OzSOa4/L729LeguuJhfRofZc0XZIiKTQ5XKUZCGR GPARhZO+27cyYqFVygM8AFZVDOwmR/GSBXHdXkr5mi/eNoFje6kglR44sMEVmIwb1rSK SBlIUlhtzFmp4s2Oc2qXh0I6uz9IB4SMrE9+lr8uEA0lW3koYX6DdKyi9vAz/NgsmSsu YvWT4zpx5drUH+89qz7c19UGp2CwjazD2bhZ1lxdjGd3TmWEEgsZuAQzwEt+R/udCRV7 10r9gXdVd9zFAEaP6szPJ8gtYedCjkWzgScTxWGYavQp15LC9uCQMS1ef+OsBc5Hu81f 78bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769192606; x=1769797406; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JcQRaSYmswErFvxepDWiHW0BBlPKFj7UEtuNsulcBmI=; b=c8dxnO/8kNTiWpdT1ayBiecFZMhSEwRlSjvkIL45f94xJ/LRWGEKVzRT0kO66iBaEd kWUjmH8uK4l/0gcChYv7O0tuiQDQUffkPBatjKsu1lP8+POfUqltoIkdtzZxPLDgSOAj zmgWbFYg+HPo/y07qk8U0yk7NJd8hoPQFvIvL50erMYUkSLEMrhWOiQ5U9EfsM29+EK4 RM/KpL2/zjt6H3EGCOn1AssPIZ/EYoFRaIleTVQwirSa6O2F20dsvpxcETCEpvrCLr7U 55Ehq0oWFj/rYYtRupXh+ZbmQal4Z4JxYdIC75K3J6B0lKd4mqcnebcZV2HnllRmunEy CjMA== X-Forwarded-Encrypted: i=1; AJvYcCWdFA2Ow92/i+XCaBhr62GsEdcqwjs6Aoh8J4igtvL2PQrWKJchR1/mMENTrH5FYGMXgE+vIyr0pkcNw6I=@vger.kernel.org X-Gm-Message-State: AOJu0Yxt5imCtVdfpZhJo586VLZiIJvBxrumlK7dEQ8hU4988udnWqiy l2z3SAD/KGOiFbHWbHn8CkW4BmqXv6tyfSGCaSEJmpCsOvsjgiEYCWtKhqS0E/4WdLla4IX1p7Q uvVyG0CjjR8FD55c6jb0OyXWarQULhk1TT5PPej06AKGs+epEtOT2pcO5bR2WLiq0Kf0= X-Gm-Gg: AZuq6aLDHghNlbEtXLBEHV9osDx6CrC7c8/m/VBHCxmCDNJ1B/jYT6/cEl9rXUVhU8+ 6enrRBDDbEw84VOC/cl9X/iWxF91Tb6LG0/TSHnmaAm/iajmk2IyZo85qZk54b+8M0deIP8qiOj YqnAnVtbBirVuEAVgWrDCKPL91tK7uszCwjkhwYaRYAf2rzDlGLz6Rf070K/PWLTpyHZJN0+U6V A/Kw16TXYhwsSlvYxM+Pcp1sblcv4AVib9MZi/DFnbmNEj/thAs9epKxJPCL+g67yHtOkbqXr6f YCV2pyHE0IUbyGDuqn+bEUY1haCeWlirbsv5dkTqjZBrxjZwONyRIptrs0dOKjqi76JrVKDoCGk IRSuZBhagaojfUX9p2bqwhznZJXY7E6pn0FFSo7BqiqvLrFXLpmHmUZIvSGgdW9oM X-Received: by 2002:a05:6102:e08:b0:5ee:a7e9:f157 with SMTP id ada2fe7eead31-5f55874884dmr572405137.40.1769192606455; Fri, 23 Jan 2026 10:23:26 -0800 (PST) X-Received: by 2002:a05:6102:e08:b0:5ee:a7e9:f157 with SMTP id ada2fe7eead31-5f55874884dmr572391137.40.1769192605953; Fri, 23 Jan 2026 10:23:25 -0800 (PST) Received: from [10.205.56.101] (84-253-213-87.bb.dnainternet.fi. [84.253.213.87]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-59de48df7e0sm836906e87.17.2026.01.23.10.23.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Jan 2026 10:23:25 -0800 (PST) Message-ID: Date: Fri, 23 Jan 2026 20:23:23 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/msm/adreno: Fix a reference leak in a6xx_gpu_init() To: Felix Gu Cc: Rob Clark , Sean Paul , Konrad Dybcio , Akhil P Oommen , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20260124-a6xx_gpu-v1-1-fa0c8b2dcfb1@gmail.com> Content-Language: en-US From: Dmitry Baryshkov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=eLUeTXp1 c=1 sm=1 tr=0 ts=6973bc9f cx=c_pps a=5HAIKLe1ejAbszaTRHs9Ug==:117 a=oW9j1mrv7lfAxSiOe78TcA==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=nHOJee6wh0HJpeXwZwgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gYDTvv6II1OnSo0itH1n:22 X-Proofpoint-GUID: lHybdUwRBP-MOBUDSLjy6z7wZLoScI_0 X-Proofpoint-ORIG-GUID: lHybdUwRBP-MOBUDSLjy6z7wZLoScI_0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTIzMDEzOSBTYWx0ZWRfX2GgO9SvNSlno ZVmywro/lzKbMuBSrctR+Ky3Lh0WW2xpr+LNuf5BZMroHxmqVM/fS2jgBf9Xj3ksbc8tnXEwqeM hirKsqCWHljfiMzxSm+ZwoUtlJb64UaaR2OvRN/BRHid7Wa8bHuh4I325zz0xgV5M9A43jeqymL S3qyy5MaXbmcJkBRo7IuE7eTkoLfATmgQK7UJCbBlLmzgF7/LguNZ+g2pbtzQ3JSXLG26n1yf0H B7XrENeYVboJk9tR1gPcLDREokWSMo+euUeV2avdURVUZJrkv1ZeJ4bEh33KJV0jo/d6lgyJIwZ XWEa8XBQ+ZdI6TfK0WdBQo1dSYhVAQSv0y3RZKXymHAiB/QO4ofTMIpRaN+ty1gVchMFnCdh3EW 7ZJhhEyHlB+UAyXShwEAGlr1iGdMTekhu7I7ucl25CO4O1eUKcW9rrnSeXnrfsmoev5vBDFIBMz zRzmwnFo5upWQ9sRl+w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.20,FMLib:17.12.100.49 definitions=2026-01-23_03,2026-01-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 adultscore=0 impostorscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2601230139 On 23/01/2026 20:21, Felix Gu wrote: > Hi Dmitry, > Thanks for your review. > linux/cleanup.h is included in linux/of.h. > So it should be included already. Yes. However we should not depend on include files being provided by other kernel-wide includes. Also, please don't top-post when replying to the emails on public MLs. > > Best regards, > Feix Gu > > On Sat, Jan 24, 2026 at 1:58 AM Dmitry Baryshkov > wrote: >> >> On Sat, Jan 24, 2026 at 12:37:38AM +0800, Felix Gu wrote: >>> In a6xx_gpu_init(), node is obtained via of_parse_phandle(). >>> While there was a manual of_node_put() at the end of the >>> common path, several early error returns would bypass this call, >>> resulting in a reference leak. >>> Fix this by using the __free(device_node) cleanup handler to >>> release the reference when the variable goes out of scope. >>> >>> Fixes: 5a903a44a984 ("drm/msm/a6xx: Introduce GMU wrapper support") >>> Signed-off-by: Felix Gu >>> --- >>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 5 ++--- >>> 1 file changed, 2 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>> index 2129d230a92b..0bc518d9fd65 100644 >>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c >>> @@ -2640,7 +2640,6 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) >>> struct msm_drm_private *priv = dev->dev_private; >>> struct platform_device *pdev = priv->gpu_pdev; >>> struct adreno_platform_config *config = pdev->dev.platform_data; >>> - struct device_node *node; >>> struct a6xx_gpu *a6xx_gpu; >>> struct adreno_gpu *adreno_gpu; >>> struct msm_gpu *gpu; >>> @@ -2660,7 +2659,8 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) >>> adreno_gpu->registers = NULL; >>> >>> /* Check if there is a GMU phandle and set it up */ >>> - node = of_parse_phandle(pdev->dev.of_node, "qcom,gmu", 0); >>> + struct device_node *node __free(device_node) = >>> + of_parse_phandle(pdev->dev.of_node, "qcom,gmu", 0); >> >> Missing include for cleanup.h. >> >>> /* FIXME: How do we gracefully handle this? */ >>> BUG_ON(!node); >>> >>> @@ -2702,7 +2702,6 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) >>> ret = a6xx_gmu_wrapper_init(a6xx_gpu, node); >>> else >>> ret = a6xx_gmu_init(a6xx_gpu, node); >>> - of_node_put(node); >>> if (ret) { >>> a6xx_destroy(&(a6xx_gpu->base.base)); >>> return ERR_PTR(ret); >>> >>> --- >>> base-commit: a0c666c25aeefd16f4b088c6549a6fb6b65a8a1d >>> change-id: 20260123-a6xx_gpu-cbc095dbe423 >>> >>> Best regards, >>> -- >>> Felix Gu >>> >> >> -- >> With best wishes >> Dmitry -- With best wishes Dmitry