Skip to contentSkip to conversation

drm/bochs: Return error from correct pointer

PATCH In review Thomas Zimmermann 2 participants 2 messages Oct 4, 2024

Subsystems (4)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

PATCH 1/1 drm/bochs: Return error from correct pointer

In probe, return the error code from the variable bochs, not dev. The variable dev has not been initialized at this point. In the case of an allocation error, the returned value would have been undefined.

Fixes 04826f588682 ("drm/bochs: Allocate DRM device in struct bochs_device")
Cc Thomas Zimmermann <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 drivers/gpu/drm/tiny/bochs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tiny/bochs.c +1 -1
index 5d2d34976d4b..3ba7f09f3e7b 100644
@@ -717,7 +717,7 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
 
 	bochs = devm_drm_dev_alloc(&pdev->dev, &bochs_driver, struct bochs_device, dev);
 	if (IS_ERR(bochs))
-		return PTR_ERR(dev);
+		return PTR_ERR(bochs);
 	dev = &bochs->dev;
 
 	ret = pcim_enable_device(pdev);
Signature · 1 line
2.46.0
Reviewed-by on v1 1/1
#1 lore raw

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 4 lines

In probe, return the error code from the variable bochs, not dev. The variable dev has not been initialized at this point. In the case of an allocation error, the returned value would have been undefined.

Quoted 8 lines
Fixes 04826f588682 ("drm/bochs: Allocate DRM device in struct bochs_device")
Cc Thomas Zimmermann <[email protected]>
Cc Gerd Hoffmann <[email protected]>

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat