mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel
@ 2017-02-23 16:45 Bastian Stender
  2017-02-23 16:45 ` [PATCH 2/3] graphic_utils: do not allocate info in fb_open Bastian Stender
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Bastian Stender @ 2017-02-23 16:45 UTC (permalink / raw)
  To: barebox; +Cc: Bastian Stender

Signed-off-by: Bastian Stender <bst@pengutronix.de>
---
 lib/gui/graphic_utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index d3f5cce4b7..f6ab5ea0d1 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -132,6 +132,7 @@ void gu_set_pixel(struct fb_info *info, void *adr, u32 px)
 {
 	switch (info->bits_per_pixel) {
 	case 8:
+		*(u8 *)adr = px & 0xff;
 		break;
 	case 16:
 		*(u16 *)adr = px & 0xffff;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] graphic_utils: do not allocate info in fb_open
  2017-02-23 16:45 [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel Bastian Stender
@ 2017-02-23 16:45 ` Bastian Stender
  2017-02-23 16:45 ` [PATCH 3/3] 2d-primitives: check dimensions in __illuminate Bastian Stender
  2017-02-24  7:24 ` [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Bastian Stender @ 2017-02-23 16:45 UTC (permalink / raw)
  To: barebox; +Cc: Bastian Stender

info was errorneously allocated, but it really is a pointer to a fb_info
struct from the framebuffer. This fixes a memory leak.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
---
 lib/gui/graphic_utils.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index f6ab5ea0d1..7d238e9ff9 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -277,8 +277,6 @@ struct screen *fb_open(const char * fbdev)
 	if (fd < 0)
 		return ERR_PTR(fd);
 
-	info = xzalloc(sizeof(*info));
-
 	ret = ioctl(fd, FBIOGET_SCREENINFO, &info);
 	if (ret) {
 		goto failed_screeninfo;
@@ -291,7 +289,6 @@ struct screen *fb_open(const char * fbdev)
 	}
 
 	sc->fd = fd;
-	sc->info = info;
 
 	return sc;
 
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] 2d-primitives: check dimensions in __illuminate
  2017-02-23 16:45 [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel Bastian Stender
  2017-02-23 16:45 ` [PATCH 2/3] graphic_utils: do not allocate info in fb_open Bastian Stender
@ 2017-02-23 16:45 ` Bastian Stender
  2017-02-24  7:24 ` [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Bastian Stender @ 2017-02-23 16:45 UTC (permalink / raw)
  To: barebox; +Cc: Bastian Stender

gl_draw_circle draws outside of the screen if the resolution is too low.
This lead to memory corruption. Check the dimensions before drawing.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
---
 lib/gui/2d-primitives.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/gui/2d-primitives.c b/lib/gui/2d-primitives.c
index f3814eea44..0f29b32bab 100644
--- a/lib/gui/2d-primitives.c
+++ b/lib/gui/2d-primitives.c
@@ -13,6 +13,9 @@ static void __illuminate(struct fb_info *info,
 {
 	void *pixel;
 
+	if (x < 0 || y < 0 || x >= info->xres || y >= info->yres)
+		return;
+
 	pixel  = fb_get_screen_base(info);
 	pixel += y * info->line_length + x * (info->bits_per_pixel >> 3);
 
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel
  2017-02-23 16:45 [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel Bastian Stender
  2017-02-23 16:45 ` [PATCH 2/3] graphic_utils: do not allocate info in fb_open Bastian Stender
  2017-02-23 16:45 ` [PATCH 3/3] 2d-primitives: check dimensions in __illuminate Bastian Stender
@ 2017-02-24  7:24 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2017-02-24  7:24 UTC (permalink / raw)
  To: Bastian Stender; +Cc: barebox

On Thu, Feb 23, 2017 at 05:45:25PM +0100, Bastian Stender wrote:
> Signed-off-by: Bastian Stender <bst@pengutronix.de>
> ---
>  lib/gui/graphic_utils.c | 1 +
>  1 file changed, 1 insertion(+)

Applied, thanks

Sascha

> 
> diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
> index d3f5cce4b7..f6ab5ea0d1 100644
> --- a/lib/gui/graphic_utils.c
> +++ b/lib/gui/graphic_utils.c
> @@ -132,6 +132,7 @@ void gu_set_pixel(struct fb_info *info, void *adr, u32 px)
>  {
>  	switch (info->bits_per_pixel) {
>  	case 8:
> +		*(u8 *)adr = px & 0xff;
>  		break;
>  	case 16:
>  		*(u16 *)adr = px & 0xffff;
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-24  7:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23 16:45 [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel Bastian Stender
2017-02-23 16:45 ` [PATCH 2/3] graphic_utils: do not allocate info in fb_open Bastian Stender
2017-02-23 16:45 ` [PATCH 3/3] 2d-primitives: check dimensions in __illuminate Bastian Stender
2017-02-24  7:24 ` [PATCH 1/3] graphic_utils: implement 8 bpp color depth in gu_set_pixel Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox