From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CB12606A31C for ; Mon, 30 Nov 2026 07:06:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=C5g+Vu3h Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9734010E87E; Mon, 30 Nov 2026 07:06:41 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5419510EA20 for ; Mon, 30 Nov 2026 07:06:35 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 0BC4F43E72; Mon, 30 Nov 2026 07:06:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC8811F00896; Mon, 30 Nov 2026 07:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796022394; bh=IvYKjW2NiztN7mm+isHz3ONlfTbIomYz2JRgmc1XMK0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=C5g+Vu3hqsyRPND1lUCFHLGk/9EYT3N2BfvZfuqDT17ZA8rH35hoKFTbIE24MwdNF NrfWsYLfm1PYItseghIixfvKMK2ThhOGywnL3q7wa4BVZUFs8Sv0n5ENmN9vz2Wq5z BPyi0Ch1daYpxqbqUCt85GhghM6cMF/9AZ/XAogs6ffVP0F56UJxEqeminDO4MYf2O PDtv2YLS2/+ZfNfDDZqKp806u8+oqp/y2rwmDGs+MzeGi2kv8dIbDeBA2Fu+EdZYPi GC2zTEvId/n9AP3IneIlLwrJ8fpX+L7exjPIzSSMDFz/tgvW3e1aL9WMWcCpKgimsL ERgxe9mncm1xQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 6/9] drm/msm/a6xx: free the preemption and pwrup_reglist buffers on destroy To: "Yuanjie Yang" Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261130-dpu_unbind_rebind_display-v1-6-c335387de1bb@oss.qualcomm.com> References: <20261130-dpu_unbind_rebind_display-v1-0-c335387de1bb@oss.qualcomm.com> <20261130-dpu_unbind_rebind_display-v1-6-c335387de1bb@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 07:06:34 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] drm/msm: double free on gpu->memptrs_bo in msm_gpu_init() [1] -- commit f46993f14cc108abd1489c5015e179df0efd70e6 Author: Yuanjie Yang drm/msm/a6xx: free the preemption and pwrup_reglist buffers on destroy This commit releases all preemption buffers in a6xx_preempt_fini() while clearing their pointers, and calls a6xx_preempt_fini() alongside freeing pwrup_reglist_bo in a6xx_destroy(). > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_preempt.c b/drivers/gpu/drm/= msm/adreno/a6xx_preempt.c > index df8d4f3e8d4c1..821c04bfed00b 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_preempt.c > +++ b/drivers/gpu/drm/msm/adreno/a6xx_preempt.c > @@ -354,8 +354,15 @@ void a6xx_preempt_fini(struct msm_gpu *gpu) > struct a6xx_gpu *a6xx_gpu =3D to_a6xx_gpu(adreno_gpu); > int i; > =20 > - for (i =3D 0; i < gpu->nr_rings; i++) > + for (i =3D 0; i < gpu->nr_rings; i++) { > msm_gem_kernel_put(a6xx_gpu->preempt_bo[i], gpu->vm); > + a6xx_gpu->preempt_bo[i] =3D NULL; > + msm_gem_kernel_put(a6xx_gpu->preempt_smmu_bo[i], gpu->vm); > + a6xx_gpu->preempt_smmu_bo[i] =3D NULL; > + } > + > + msm_gem_kernel_put(a6xx_gpu->preempt_postamble_bo, gpu->vm); > + a6xx_gpu->preempt_postamble_bo =3D NULL; > } > =20 > void a6xx_preempt_init(struct msm_gpu *gpu) [Severity: Critical] This problem wasn't introduced by this patch, but can gpu->memptrs_bo be double freed [1] if msm_gpu_init() fails after allocating it? drivers/gpu/drm/msm/msm_gpu.c:msm_gpu_init() { ... fail: for (i =3D 0; i < ARRAY_SIZE(gpu->rb); i++) { msm_ringbuffer_destroy(gpu->rb[i]); gpu->rb[i] =3D NULL; } msm_gem_kernel_put(gpu->memptrs_bo, gpu->vm); platform_set_drvdata(pdev, NULL); return ret; } When a step such as msm_ringbuffer_new() fails, msm_gpu_init() releases gpu->memptrs_bo without clearing the pointer to NULL. The caller's error path (for example a6xx_gpu_init() -> a6xx_destroy() -> adreno_gpu_cleanup() -> msm_gpu_cleanup()) then calls msm_gem_kernel_put(gpu->memptrs_bo, gpu->vm) a second time on the already-freed GEM object. [1] https://sashiko.dev/#/bug/linux-ee423138-c527-467c-b053-bdbec97b4f9c --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-dpu_unbind= _rebind_display-v1-0-c335387de1bb@oss.qualcomm.com?part=3D6