From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796023233; b=uLLkRBGHup8sW7fKrOoCzDiihPAJ/gsE4c3WL+eItnGFa+BqsfaeFjW9OAzd7FzHvrT+ dK/tt79EnEEPkmTEQniLBOsohq9dHDUUIiz0DbodTCS0E5MEQZXxeHoVEWQQ4by00cykV ee18mclQMe+0biZZqIzOddluQRBkqGCQ9yxNWNNQPXmJctRd4/1CQiIyUV7Hz6wJFfRYO TRl+a6q4xR+aPh4BzezOyzb/hoVPB0A0xmRvkpcolEqZlgzAfLOiwhqKpv0gz/02nQWNW fggZG1xx05LsunhmU4E2U3E2mdSWTAiLs5ZxX6cMverITeOBZh9rvi09M7Ad3W7pDfg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796023233; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=XiOAimFEEktOTMTTkY4uW6EOfgHDYd/VPJLG1DUYnRg=; b=ojn3j3fTr7hrjqsHrw2L7Usjwrufm1G1JumOg9AISJTH49t0GhVXMfFLwoWv2KPCxFVg HyKhCCnXFzKpu8iowre+ptAJYSfzBRrhbanzFtJJIQxnO/F1/X/6RA7+o1HXk0lU1XjbR N49aGZI+uw4IzYIRLps/Y5vBbRUwfwED0hlz432VJRNKmdY4jmCLZcinBeFQ5n6nuSSi9 QWitQVok8k0TxOiydFCUpkaM+QedaqKFJsPiEag2VaWc2/cDdAYrfrlXyFWyh4trfqswO p2Ov8TMWnNZ9FWs/VFUrVFY/JEWxLZr44K8DC+zow7fIdbQC2UzpGXlsNzIu6oCAYGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kc93Qw6I; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EFEF606A31C for ; Mon, 30 Nov 2026 07:20:33 +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=kc93Qw6I Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7B521F00898; Mon, 30 Nov 2026 07:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796023232; bh=XiOAimFEEktOTMTTkY4uW6EOfgHDYd/VPJLG1DUYnRg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kc93Qw6IX5Nsp/3TMUEUY+emH8LUuhz7JwZ/fVk/kdrC1ZvbbeERseGl8dw5Sxprt nQ8H/hArNkG9iML5ux/z8gK+5He+JFpn5sZ3isy219Or1Op367SgyD+JWpD2wGcMAq 71I5uMh5gPovFnMcQz31A3r/ZzVaz7yhjXe3SnC/WfbTXMRd2jGMAAI0+TUUoyvhs+ AYwPEUIMcKFSdtD6BxAIqmP4YHzDYcbQUtkzzLQLPfN0Uisfahexb8rdf3fQ4LxiTT Ke1gedvUyTJVHm2J75imfvhm6cKfYAoVBspi7Ztc7oqFyHTb2eCczO/Q46KDnBZnGU fSaZSYOO7/aRw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 3/8] coresight: tmc: factor out common ETR probe initialisation Reply-To: sashiko-reviews@lists.linux.dev To: "Jie Gan" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261130-introduce-qcom-qecp-feature-v2-3-dff9ae87327b@oss.qualcomm.com> References: <20261130-introduce-qcom-qecp-feature-v2-0-dff9ae87327b@oss.qualcomm.com> <20261130-introduce-qcom-qecp-feature-v2-3-dff9ae87327b@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 07:20:32 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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: - [High] coresight: tmc: invalid csdev access and resource leaks in __tmc_probe() [1] -- commit 287401d1d1c361e6772a54be5797715a0d04a2cd Author: Jie Gan coresight: tmc: factor out common ETR probe initialisation This commit moves the ETR probe setup derived from DEVID and firmware properties into tmc_etr_probe_common(), leaving tmc_etr_setup_caps() with the register-based checks. > diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/h= wtracing/coresight/coresight-tmc-core.c > index 0ef4b817b297d..ad2c99eae5aed 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-core.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c [ ... ] > @@ -829,11 +847,12 @@ static int __tmc_probe(struct device *dev, struct r= esource *res) > desc.type =3D CORESIGHT_DEV_TYPE_SINK; > desc.subtype.sink_subtype =3D CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM; > desc.ops =3D &tmc_etr_cs_ops; > - ret =3D tmc_etr_setup_caps(dev, devid, &desc.access); > + ret =3D tmc_etr_setup_caps(dev, &desc.access); > + if (ret) > + goto out; > + ret =3D tmc_etr_probe_common(dev, drvdata, devid); > if (ret) > goto out; > - idr_init(&drvdata->idr); > - mutex_init(&drvdata->idr_mutex); > dev_list =3D "tmc_etr"; > break; > case TMC_CONFIG_TYPE_ETF: [Severity: High] This problem wasn't introduced by this patch, but can jumping to out after tmc_get_reserved_region() dereference an invalid drvdata->csdev [1]? drivers/hwtracing/coresight/coresight-tmc-core.c:__tmc_probe() { ... out: if (is_tmc_crashdata_valid(drvdata) && !tmc_prepare_crashdata(drvdata)) register_crash_dev_interface(drvdata, desc.name); return ret; } When probe fails after tmc_get_reserved_region() maps valid crash trace data, the out path runs is_tmc_crashdata_valid(), tmc_prepare_crashdata(), and register_crash_dev_interface(). All three dereference &drvdata->csdev->dev while drvdata->csdev is still NULL, an ERR_PTR() from coresight_register(), or already freed by coresight_unregister(). If register_crash_dev_interface() succeeds on an error path, misc_register() also links drvdata->crashdev into misc_list right before devres frees drvdata. In addition, the unmanaged memremap() mappings in drvdata->resrv_buf.vaddr and drvdata->crash_mdata.vaddr are never unmapped on probe failure or in __tmc_remove(). [1] https://sashiko.dev/#/bug/linux-f23df7b7-bae5-4fa0-96ef-4e83632058e8 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-introduce-= qcom-qecp-feature-v2-0-dff9ae87327b@oss.qualcomm.com?part=3D3