Wentao Liang <[email protected]> writes:

Hello Wentao,

> Hi Thomas, Alex,
>
> Sorry for the very late reply, and thanks for the review.
>
> Alex, you asked whether sysfb_unregister() would still need to be called
> when the parent device lookup returns an error. It does: without a known
> parent we cannot tell whether the system framebuffer belongs to the
> calling device, and leaving it registered could make sysfb interfere with
> the native driver. Thomas, that is the defensive behaviour you suggested,
> so v2 unregisters unconditionally when sysfb_parent_dev() fails and only
> drops the reference on the non-error path.
>
> The reference leak fix itself is unchanged.
>
> From 8c5f084941a3b6aca5d3ae8cff0c3bd1d4ae1e6f Mon Sep 17 00:00:00 2001
> From: Wentao Liang <[email protected]>
> Date: Sat, 7 Nov 2026 17:02:27 +0000
> Subject: [PATCH v2] firmware/sysfb: Fix device reference count leak in
>  sysfb_disable()
>

Could you please post this as a separate thread? Otherwise I'm not sure if
tools like patman or dim would handle your patch correctly.

> sysfb_parent_dev() returns a pointer to &pdev->dev with an acquired
> reference when it finds the PCI device that contains the system
> framebuffer. sysfb_disable() never drops that reference, so a reference
> to the PCI device is leaked on every call that resolves a parent.
>
> Release the reference with put_device() before leaving the critical
> section.
>
> If the parent device cannot be determined, unregister the system
> framebuffer unconditionally, as it might still belong to the calling
> device. Leaving sysfb registered in that case can make it interfere
> with the native driver.
>
> Fixes: b49420d6a1ae ("video/aperture: optionally match the device in 
> sysfb_disable()")
> Cc: [email protected]
> Signed-off-by: Wentao Liang <[email protected]>
> ---
> Changes in v2:
> - Sorry for the late reply.
> - Unregister the system framebuffer when the parent device lookup fails,
>   as pointed out by Alex Deucher and Thomas Zimmermann.
>
> Disclosure: the candidate was found with our static analysis tooling, and
> the audit and the fix were assisted by DeepSeek and GPT 6.1 sol.
> ---
>  drivers/firmware/sysfb.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>

This change makes sense to me.

Reviewed-by: Javier Martinez Canillas <[email protected]>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat

Reply via email to