Skip to content

Commit 5bdea60

Browse files
Navidemgregkh
authored andcommitted
Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc
In fbtft_framebuffer_alloc the error handling path should take care of releasing frame buffer after it is allocated via framebuffer_alloc, too. Therefore, in two failure cases the goto destination is changed to address this issue. Fixes: c296d5f ("staging: fbtft: core support") Signed-off-by: Navid Emamdoost <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5dcaa1f commit 5bdea60

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/staging/fbtft/fbtft-core.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
714714
if (par->gamma.curves && gamma) {
715715
if (fbtft_gamma_parse_str(par, par->gamma.curves, gamma,
716716
strlen(gamma)))
717-
goto alloc_fail;
717+
goto release_framebuf;
718718
}
719719

720720
/* Transmit buffer */
@@ -731,7 +731,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
731731
if (txbuflen > 0) {
732732
txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL);
733733
if (!txbuf)
734-
goto alloc_fail;
734+
goto release_framebuf;
735735
par->txbuf.buf = txbuf;
736736
par->txbuf.len = txbuflen;
737737
}
@@ -753,6 +753,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
753753

754754
return info;
755755

756+
release_framebuf:
757+
framebuffer_release(info);
758+
756759
alloc_fail:
757760
vfree(vmem);
758761

0 commit comments

Comments
 (0)