public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] dfu:function: Fix number of allocated DFU function pointers
@ 2013-06-26  9:46 Lukasz Majewski
  2013-06-26 11:35 ` Heiko Schocher
  0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Majewski @ 2013-06-26  9:46 UTC (permalink / raw)
  To: u-boot

This subtle change fix problem with too small amount of allocated
memory to store DFU function pointers.

One needs to allocate extra space for sentinel NULL pointer in this array
of function pointers.

With the previous code, the NULL value overwrites malloc internal data
and afterwards free(f_dfu->function) crashes.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
 drivers/usb/gadget/f_dfu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 178a004..e3fa0e3 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -589,7 +589,7 @@ static int dfu_prepare_function(struct f_dfu *f_dfu, int n)
 	struct usb_interface_descriptor *d;
 	int i = 0;
 
-	f_dfu->function = calloc(sizeof(struct usb_descriptor_header *), n);
+	f_dfu->function = calloc(sizeof(struct usb_descriptor_header *), n + 1);
 	if (!f_dfu->function)
 		goto enomem;
 
-- 
1.7.10.4

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

* [U-Boot] [PATCH] dfu:function: Fix number of allocated DFU function pointers
  2013-06-26  9:46 [U-Boot] [PATCH] dfu:function: Fix number of allocated DFU function pointers Lukasz Majewski
@ 2013-06-26 11:35 ` Heiko Schocher
  2013-06-26 12:07   ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Schocher @ 2013-06-26 11:35 UTC (permalink / raw)
  To: u-boot

Hello Lukasz,

Am 26.06.2013 11:46, schrieb Lukasz Majewski:
> This subtle change fix problem with too small amount of allocated
> memory to store DFU function pointers.
> 
> One needs to allocate extra space for sentinel NULL pointer in this array
> of function pointers.
> 
> With the previous code, the NULL value overwrites malloc internal data
> and afterwards free(f_dfu->function) crashes.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
>  drivers/usb/gadget/f_dfu.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Heiko Schocher <hs@denx.de>

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH] dfu:function: Fix number of allocated DFU function pointers
  2013-06-26 11:35 ` Heiko Schocher
@ 2013-06-26 12:07   ` Marek Vasut
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2013-06-26 12:07 UTC (permalink / raw)
  To: u-boot

Dear Heiko Schocher,

> Hello Lukasz,
> 
> Am 26.06.2013 11:46, schrieb Lukasz Majewski:
> > This subtle change fix problem with too small amount of allocated
> > memory to store DFU function pointers.
> > 
> > One needs to allocate extra space for sentinel NULL pointer in this array
> > of function pointers.
> > 
> > With the previous code, the NULL value overwrites malloc internal data
> > and afterwards free(f_dfu->function) crashes.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> > Cc: Marek Vasut <marex@denx.de>
> > ---
> > 
> >  drivers/usb/gadget/f_dfu.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Acked-by: Heiko Schocher <hs@denx.de>

Applied, thanks

Best regards,
Marek Vasut

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

end of thread, other threads:[~2013-06-26 12:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-26  9:46 [U-Boot] [PATCH] dfu:function: Fix number of allocated DFU function pointers Lukasz Majewski
2013-06-26 11:35 ` Heiko Schocher
2013-06-26 12:07   ` Marek Vasut

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