From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 CF3D941834A for ; Wed, 23 Sep 2026 08:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790153421; cv=none; b=URqEUYG/BS1pU7VG8hOt1SOIcCQAVhyAAxyIPENQSGHXlp8QU+rWOWWr+sCqqobl9vQS7eyVNFqFpqSej0B3z6DfsVR1Ml8ucPbFD4FgktZzTcsYVoFvHG2sdS/RxWsUva896hgpGBbUSdACkhECiDQsKgLwNdjDQz7ifQUpY7Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790153421; c=relaxed/simple; bh=e96I/xgTkEFtIObm1G8ysPq450W7WEEGNoetlQLGUzk=; h=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Date: Message-Id; b=lLye6elLOjvqkvZl0wcky3AmO4sNfaWgOticiT5W7/m68M8pIpFoNeaUZh7xyIf31WxIxkgkEGiU7wXt3vS3LzkOzfXzRLR0Obw1HMae5f0rdtQqsG410CPkuvijzPqdHmI5lDDZ61AvYW85AVzHmPEcrHZbzhgPZhSYNm8/OGw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U0/hgMRo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U0/hgMRo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 719551F000FF; Wed, 23 Sep 2026 08:50:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790153419; bh=PaLiowRkPvkzHWsoVbcartkgXvyXnuaFcZ9i0jYYz/c=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=U0/hgMRo6UYv/r2XsQb643tW7V+E27qu7s3bQ8vDrgSFrRCCBfnMWxMJeshHklPBI 12Jdt/19h/NQgPGX+6WkSEmxNWGDtPU6tt0KUBRZ4d+WToPz/iP54oAqRNBs4BrfHU c969O26X4IFGg3dr1mPVwVR4Bfb6X1fLOKVt8NSdjVnxO+6qNV+tRurSWckd52yfBQ 6A/DaavXrNNMvrocX/ENKe0am29ertVhzimvaWl7seQqQjBgDC/D4Be9VUosqKJosp 6DGWTLySkSdQQIWDZ8Wrzc40GADoHszai1cmPbTt1HAzyPlqBPFeMOEhKxNkmBULJa eqZIGlab+gXDg== From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 3/3] dt-bindings: misc: qcom,fastrpc: deprecate qcom,nsessions Reply-To: sashiko-reviews@lists.linux.dev To: "Vinayak Katoch" Cc: robh@kernel.org, conor+dt@kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org In-Reply-To: <20260923-dup-sessions-v5-3-e953133a1827@oss.qualcomm.com> References: <20260923-dup-sessions-v5-0-e953133a1827@oss.qualcomm.com> <20260923-dup-sessions-v5-3-e953133a1827@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 23 Sep 2026 08:50:18 +0000 Message-Id: <20260923085019.719551F000FF@smtp.kernel.org> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Thank you for your contribution! Sashiko AI review found 2 potential issue(= s) to consider: - [High] of: use-after-free and double put on device tree node during itera= tion - [Medium] device: memory leak due to missing put_device() after of_find_de= vice_by_node() -- commit 0cd61e434e0b0defac9c431333bfa40bb39df800 Author: Vinayak Katoch misc: fastrpc: iterate CB nodes manually instead of of_platform_populate This commit replaces of_platform_populate() with manual iteration of device tree child nodes to ensure context banks are fully initialised before fastrpc_rpmsg_probe() returns. It introduces fastrpc_cb_devices_create() and fastrpc_cb_devices_destroy() to handle this synchronous setup and teardown. > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index af18ff1992eed..f20d3e5ecc81f 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c [ ... ] > @@ -2389,37 +2389,63 @@ static int fastrpc_cb_probe(struct platform_devic= e *pdev) > return 0; > } > =20 > -static void fastrpc_cb_remove(struct platform_device *pdev) > +static void fastrpc_cb_devices_destroy(struct rpmsg_device *rpdev) > { > - struct fastrpc_channel_ctx *cctx =3D dev_get_drvdata(pdev->dev.parent); > - struct fastrpc_session_ctx *sess =3D dev_get_drvdata(&pdev->dev); > + struct fastrpc_channel_ctx *cctx =3D dev_get_drvdata(&rpdev->dev); > + struct device *rdev =3D &rpdev->dev; > + struct platform_device *pdev; > + struct device_node *np; > unsigned long flags; > int i; > =20 > spin_lock_irqsave(&cctx->lock, flags); > - for (i =3D 0; i < FASTRPC_MAX_SESSIONS; i++) { > - if (cctx->session[i].sid =3D=3D sess->sid) { > - cctx->session[i].valid =3D false; > - cctx->sesscount--; > + for (i =3D 0; i < cctx->sesscount; i++) > + cctx->session[i].valid =3D false; > + spin_unlock_irqrestore(&cctx->lock, flags); > + > + for_each_available_child_of_node(rdev->of_node, np) { > + if (!of_device_is_compatible(np, "qcom,fastrpc-compute-cb")) { > + of_node_put(np); > + continue; > } [Severity: High] Can this result in a double-put and use-after-free on the device tree node? The for_each_available_child_of_node() macro automatically handles dropping the reference on the current child node at the end of each iteration via of_get_next_available_child(). Calling of_node_put(np) manually before continue causes the iterator to dereference np->sibling on the already-freed node, followed by a second of_node_put(np) that underflows the reference count. > + > + pdev =3D of_find_device_by_node(np); > + of_node_put(np); [Severity: High] Will this manual of_node_put() lead to the same use-after-free issue? Calling of_node_put(np) manually at the end of the loop body causes the same issue with the loop macro underflowing the reference count and accessing the freed node during iteration. > + if (pdev) > + of_platform_device_destroy(&pdev->dev, NULL); [Severity: Medium] Could this leak the pdev device reference? of_find_device_by_node() acquires a device reference by incrementing its refcount. This reference doesn't appear to be released via put_device(&pdev= ->dev) or platform_device_put(pdev) after calling of_platform_device_destroy(). > } > - spin_unlock_irqrestore(&cctx->lock, flags); > } > =20 > -static const struct of_device_id fastrpc_match_table[] =3D { > - { .compatible =3D "qcom,fastrpc-compute-cb" }, > - { } > -}; > +static int fastrpc_cb_devices_create(struct rpmsg_device *rpdev) > +{ > + struct device *rdev =3D &rpdev->dev; > + struct platform_device *pdev; > + struct device_node *np; > + int err; > =20 > -static struct platform_driver fastrpc_cb_driver =3D { > - .probe =3D fastrpc_cb_probe, > - .remove =3D fastrpc_cb_remove, > - .driver =3D { > - .name =3D "qcom,fastrpc-cb", > - .of_match_table =3D fastrpc_match_table, > - .suppress_bind_attrs =3D true, > - }, > -}; > + for_each_available_child_of_node(rdev->of_node, np) { > + if (!of_device_is_compatible(np, "qcom,fastrpc-compute-cb")) { > + of_node_put(np); > + continue; > + } [Severity: High] Does this early of_node_put() cause a similar double-put and use-after-free during the loop iteration? Similar to fastrpc_cb_devices_destroy(), calling of_node_put(np) before continue will double-put the node and use-after-free np->sibling during the loop iteration. > + > + pdev =3D of_platform_device_create(np, NULL, rdev); [ ... ] --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260923-dup-sessio= ns-v5-0-e953133a1827@oss.qualcomm.com?part=3D3