Skip to contentSkip to conversation

video: Add missing free for logo memory

PATCH New Matthias Fuchs 3 participants 4 messages Apr 18, 2008 – Apr 21, 2008 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: Add missing free for logo memory

This patch adds some missing free()s and does some coding style clean up.

---
 drivers/video/cfb_console.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/video/cfb_console.c +6 -4
index 4f73067..751c2c4 100644
@@ -830,7 +830,7 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 		dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE);
 		if (dst == NULL) {
 			printf("Error: malloc in gunzip failed!\n");
-			return(1);
+			return 1;
 		}
 		if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)bmp_image, &len) != 0) {
 			printf ("Error: no valid bmp or bmp.gz image at %lx\n", bmp_image);
@@ -849,6 +849,7 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 		if (!((bmp->header.signature[0] == 'B') &&
 		      (bmp->header.signature[1] == 'M'))) {
 			printf ("Error: no valid bmp.gz image at %lx\n", bmp_image);
+			free(dst);
 			return 1;
 		}
 #else
@@ -869,6 +870,8 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 	if (compression != BMP_BI_RGB) {
 		printf ("Error: compression type %ld not supported\n",
 			compression);
+		if (dst)
+			free(dst);
 		return 1;
 	}
 
@@ -1046,12 +1049,11 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 	}
 
 #ifdef CONFIG_VIDEO_BMP_GZIP
-	if (dst) {
+	if (dst)
 		free(dst);
-	}
 #endif
 
-	return (0);
+	return 0;
 }
 #endif
 
Signature · 1 line
1.5.3
#1 lore raw

PATCH 1/1 video: Add missing free for logo memory

Quoted 1 line · Matthias Fuchs

This patch adds some missing free()s and does some coding style clean up.

Please, separate the patches or just send the one which fixes memory allocation only.

Quoted 19 lines
---
 drivers/video/cfb_console.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/video/cfb_console.c +1 -1
index 4f73067..751c2c4 100644
@@ -830,7 +830,7 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 		dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE);
 		if (dst == NULL) {
 			printf("Error: malloc in gunzip failed!\n");
-			return(1);
+			return 1;
 		}
 		if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)bmp_image, &len) != 0) {
 			printf ("Error: no valid bmp or bmp.gz image at %lx\n", bmp_image);

drivers/video/cfb_console.c int video_display_bitmap (ulong bmp_image, int x, int y) · line 852

Quoted 4 lines
drivers/video/cfb_console.c +1 -0
@@ -849,6 +849,7 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 		if (!((bmp->header.signature[0] == 'B') &&
 		      (bmp->header.signature[1] == 'M'))) {
 			printf ("Error: no valid bmp.gz image at %lx\n", bmp_image);
+			free(dst);

Do you need checking for dst==NULL? (see below)

drivers/video/cfb_console.c int video_display_bitmap (ulong bmp_image, int x, int y) · line 874

Quoted 9 lines
drivers/video/cfb_console.c +2 -0
 			return 1;
 		}
 #else
@@ -869,6 +870,8 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 	if (compression != BMP_BI_RGB) {
 		printf ("Error: compression type %ld not supported\n",
 			compression);
+		if (dst)
+			free(dst);

Maybe you don't need checking for dst==NULL... (see above)

drivers/video/cfb_console.c int video_display_bitmap (ulong bmp_image, int x, int y) · line 1053

Quoted 10 lines
drivers/video/cfb_console.c +1 -1
 		return 1;
 	}
 
@@ -1046,12 +1049,11 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 	}
 
 #ifdef CONFIG_VIDEO_BMP_GZIP
-	if (dst) {
+	if (dst)
 		free(dst);

Ditto.

Quoted 10 lines
drivers/video/cfb_console.c +1 -2
-	}
 #endif
 
-	return (0);
+	return 0;
 }
 #endif
 
Signature · 1 line
1.5.3

Thanks,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail:    giometti at enneenne.com
Linux Device Driver                             giometti at linux.it
Embedded Systems                     phone:	+39 349 2432127
UNIX programming                     skype:     rodolfo.giometti
#2 lore raw

PATCH 1/1 video: Add missing free for logo memory

Quoted 5 lines · Rodolfo Giometti
Quoted 1 line · Matthias Fuchs

This patch adds some missing free()s and does some coding style clean up.

Please, separate the patches or just send the one which fixes memory allocation only.

Please see my comments below. I will resubmit the patch. But w/o the cleanup.

Matthias

Quoted 18 lines
Quoted 18 lines
---
 drivers/video/cfb_console.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/video/cfb_console.c +1 -1
index 4f73067..751c2c4 100644
@@ -830,7 +830,7 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 		dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE);
 		if (dst == NULL) {
 			printf("Error: malloc in gunzip failed!\n");
-			return(1);
+			return 1;
 		}
 		if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)bmp_image, &len) != 0) {
Quoted 8 lines

drivers/video/cfb_console.c int video_display_bitmap (ulong bmp_image, int x, int y) · line 852

Quoted 6 lines
drivers/video/cfb_console.c +1 -0
 			printf ("Error: no valid bmp or bmp.gz image at %lx\n", bmp_image);
@@ -849,6 +849,7 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 		if (!((bmp->header.signature[0] == 'B') &&
 		      (bmp->header.signature[1] == 'M'))) {
 			printf ("Error: no valid bmp.gz image at %lx\n", bmp_image);
+			free(dst);

Do you need checking for dst==NULL? (see below)

No, not here!

Quoted 12 lines

drivers/video/cfb_console.c int video_display_bitmap (ulong bmp_image, int x, int y) · line 874

Quoted 10 lines
drivers/video/cfb_console.c +2 -0
 			return 1;
 		}
 #else
@@ -869,6 +870,8 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 	if (compression != BMP_BI_RGB) {
 		printf ("Error: compression type %ld not supported\n",
 			compression);
+		if (dst)
+			free(dst);

Maybe you don't need checking for dst==NULL... (see above)

You need it! But I forgot to add the #ifdef CONFIG_VIDEO_BMP_GZIP.

Quoted 29 lines

drivers/video/cfb_console.c int video_display_bitmap (ulong bmp_image, int x, int y) · line 1053

Quoted 11 lines
drivers/video/cfb_console.c +1 -1
 		return 1;
 	}
 
@@ -1046,12 +1049,11 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
 	}
 
 #ifdef CONFIG_VIDEO_BMP_GZIP
-	if (dst) {
+	if (dst)
 		free(dst);

Ditto.

Quoted 10 lines
drivers/video/cfb_console.c +1 -2
-	}
 #endif
 
-	return (0);
+	return 0;
 }
 #endif
 
Signature · 1 line
1.5.3

Thanks,

Rodolfo

#3 lore raw

PATCH 1/1 video: Add missing free for logo memory

In reply to Rodolfo Giometti
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 1 line · Matthias Fuchs

This patch adds some missing free()s and does some coding style clean up.

Please, separate the patches or just send the one which fixes memory allocation only.

In principle you are right, but I think this is still acceptable. Please turn a blind eye...

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Beware of bugs in the above code; I have only proved it correct, not
tried it."                                             - Donald Knuth