Skip to content

Commit 0ba03e0

Browse files
ISCAS-Vulabgregkh
authored andcommitted
of: unittest: fix use-after-free in testdrv_probe()
commit 07fd339 upstream. The function testdrv_probe() retrieves the device_node from the PCI device, applies an overlay, and then immediately calls of_node_put(dn). This releases the reference held by the PCI core, potentially freeing the node if the reference count drops to zero. Later, the same freed pointer 'dn' is passed to of_platform_default_populate(), leading to a use-after-free. The reference to pdev->dev.of_node is owned by the device model and should not be released by the driver. Remove the erroneous of_node_put() to prevent premature freeing. Fixes: 26409dd ("of: unittest: Add pci_dt_testdrv pci driver") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Link: https://patch.msgid.link/20260409034859.429071-1-vulab@iscas.ac.cn Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9f1cbca commit 0ba03e0

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

drivers/of/unittest.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3862,7 +3862,6 @@ static int testdrv_probe(struct pci_dev *pdev, const struct pci_device_id *id)
38623862

38633863
size = info->dtbo_end - info->dtbo_begin;
38643864
ret = of_overlay_fdt_apply(info->dtbo_begin, size, &ovcs_id, dn);
3865-
of_node_put(dn);
38663865
if (ret)
38673866
return ret;
38683867

0 commit comments

Comments
 (0)