Re: [PATCH v2] staging: sm750fb: free cmap on framebuffer release

From: Dan Carpenter

Date: Tue Sep 22 2026 - 12:42:05 EST


On Tue, Sep 22, 2026 at 11:28:51AM -0300, Lucas Costa wrote:
> The cmap is allocated by lynxfb_set_fbinfo() but never freed, so it is
> leaked when the framebuffer is torn down. This happens on every unbind,
> and on the register_framebuffer() error path in
> sm750fb_framebuffer_alloc().
>
> Add a lynxfb_unset_fbinfo() cleanup counterpart to lynxfb_set_fbinfo()
> which deallocates the cmap, and call it on teardown. In the alloc error
> path it is only called once lynxfb_set_fbinfo() has succeeded, so the
> cmap is only freed when it was actually allocated.
>
> Fixes: 81dee67e215b ("staging: sm750fb: add sm750 to staging")
> Suggested-by: Dan Carpenter <error27@xxxxxxxxx>
> Signed-off-by: Lucas Costa <2000.costalucas@xxxxxxxxx>
> ---
> v2:
> - Move the cmap deallocation into a lynxfb_unset_fbinfo() cleanup
> counterpart to lynxfb_set_fbinfo(), instead of open-coding
> fb_dealloc_cmap() at each call site.
> - In the alloc error path, only unwind the cmap once
> lynxfb_set_fbinfo() has succeeded (Dan Carpenter).

Thanks!

Reviewed-by: Dan Carpenter <error27@xxxxxxxxx>

regards,
dan carpenter