hw/display/tcx.c: tcx_realizefn: fix memory leak, make FCode loading error fatal and improve error message
PATCH 2/2 hw/display/tcx.c: tcx_realizefn: fix memory leak, make FCode loading error fatal and improve error message
Signed-off-by Michael Tokarev <[email protected]>
--- hw/display/tcx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
hw/display/tcx.c +6 -3
@@ -1014,10 +1014,13 @@ static void tcx_realizefn(DeviceState *dev, Error **errp)if (fcode_filename) { ret =load_image_targphys (fcode_filename, s->prom_addr,FCODE_MAX_ROM_SIZE ); -if (ret <0 || ret >FCODE_MAX_ROM_SIZE ) { -error_report ("tcx: could not load prom '%s'" ,TCX_ROM_FILE ); - } } +if (!fcode_filename || ret <0 || ret >FCODE_MAX_ROM_SIZE ) { +error_report ("tcx: could not load prom '%s'" , + fcode_filename ? fcode_filename :TCX_ROM_FILE ); +exit (1 ); + } +g_free (fcode_filename);/* 0/DFB8 : 8-bit plane */ s->vram = vram_base;
Signature · 1 line
2.1.4
Quoted 1 line · Michael Tokarev
Signed-off-by Michael Tokarev <[email protected]>
Reviewed-by Shannon Zhao <[email protected]>
Quoted 26 lines
--- hw/display/tcx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)hw/display/tcx.c +6
-3@@ -1014,10 +1014,13 @@ static void tcx_realizefn(DeviceState *dev, Error **errp)if (fcode_filename) { ret =load_image_targphys (fcode_filename, s->prom_addr,FCODE_MAX_ROM_SIZE ); -if (ret <0 || ret >FCODE_MAX_ROM_SIZE ) { -error_report ("tcx: could not load prom '%s'" ,TCX_ROM_FILE ); - } } +if (!fcode_filename || ret <0 || ret >FCODE_MAX_ROM_SIZE ) { +error_report ("tcx: could not load prom '%s'" , + fcode_filename ? fcode_filename :TCX_ROM_FILE ); +exit (1 ); + } +g_free (fcode_filename);/* 0/DFB8 : 8-bit plane */ s->vram = vram_base;
Signature · 1 line
Shannon