drm/gma500: Fix null dereference in hdmi teardown

[ Upstream commit 352e66900c ]

pci_set_drvdata sets the value of pdev->driver_data to NULL,
after which the driver_data obtained from the same dev is
dereferenced in oaktrail_hdmi_i2c_exit, and the i2c_dev is
extracted from it. To prevent this, swap these calls.

Found by Linux Verification Center (linuxtesting.org) with Svacer.

Fixes: 1b082ccf59 ("gma500: Add Oaktrail support")
Signed-off-by: Zabelin Nikita <n.zabelin@mt-integration.ru>
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://lore.kernel.org/r/20250918150703.2562604-1-n.zabelin@mt-integration.ru
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Zabelin Nikita
2025-09-18 18:06:59 +03:00
committed by Greg Kroah-Hartman
parent 895fab2a42
commit f800f7054d

View File

@@ -726,8 +726,8 @@ void oaktrail_hdmi_teardown(struct drm_device *dev)
if (hdmi_dev) { if (hdmi_dev) {
pdev = hdmi_dev->dev; pdev = hdmi_dev->dev;
pci_set_drvdata(pdev, NULL);
oaktrail_hdmi_i2c_exit(pdev); oaktrail_hdmi_i2c_exit(pdev);
pci_set_drvdata(pdev, NULL);
iounmap(hdmi_dev->regs); iounmap(hdmi_dev->regs);
kfree(hdmi_dev); kfree(hdmi_dev);
pci_dev_put(pdev); pci_dev_put(pdev);