Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-10-16 Thread Graeme Russ
Hi Wolfgang, On Tue, Oct 16, 2012 at 9:43 PM, Wolfgang Denk wrote: > Dear Marek Vasut, > > In message <201210160831.20759.ma...@denx.de> you wrote: >> >> > In short, returning non-NULL from malloc(0) and expecting a CPU exception >> > when it is de-referenced is not going to fly. > > We should no

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-10-16 Thread Joakim Tjernlund
Marek Vasut wrote on 2012/10/16 12:43:08: > > Dear Joakim Tjernlund, > > [...] > > > > do about this patch? > > > > Skip the idea to protect a page, this is too complicated for a boot > > loader. Just > > treat malloc(0) as malloc(1) internally. > > I was more interested in knowing if we shou

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-10-16 Thread Wolfgang Denk
Dear Marek Vasut, In message <201210160831.20759.ma...@denx.de> you wrote: > > > In short, returning non-NULL from malloc(0) and expecting a CPU exception > > when it is de-referenced is not going to fly. We should not expect to have support for any exceptions for any kind of illegal accesses.

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-10-16 Thread Marek Vasut
Dear Joakim Tjernlund, [...] > > do about this patch? > > Skip the idea to protect a page, this is too complicated for a boot > loader. Just > treat malloc(0) as malloc(1) internally. I was more interested in knowing if we should drop the patch or what ... ? Best regards, Marek Vasut _

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-10-16 Thread Joakim Tjernlund
Marek Vasut wrote on 2012/10/16 08:31:20: > > Dear Graeme Russ, > > > On 04/03/2012 09:35 AM, Graeme Russ wrote: > > > Hi Jocke > > > > > > And I really need to check, but I have a sneaking suspicion that as the > > > code currently stands in U-Boot/x86 dereferencing a NULL pointer won't > >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-10-15 Thread Marek Vasut
Dear Graeme Russ, > On 04/03/2012 09:35 AM, Graeme Russ wrote: > > Hi Jocke > > > > And I really need to check, but I have a sneaking suspicion that as the > > code currently stands in U-Boot/x86 dereferencing a NULL pointer won't > > cause an exception. In x86, U-Boot configures all protected mo

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-03 Thread Graeme Russ
On 04/03/2012 09:35 AM, Graeme Russ wrote: > Hi Jocke > And I really need to check, but I have a sneaking suspicion that as the > code currently stands in U-Boot/x86 dereferencing a NULL pointer won't > cause an exception. In x86, U-Boot configures all protected mode segments > to be 4GB starting

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Graeme Russ
Hi Jocke On Tue, Apr 3, 2012 at 7:14 AM, Joakim Tjernlund wrote: > Graeme Russ wrote on 2012/04/02 22:59:57: >> >> >> On Apr 3, 2012 6:57 AM, "Joakim Tjernlund" >> wrote: >> > >> > Graeme Russ wrote on 2012/04/02 22:28:46: >> > > From: Graeme Russ >> > > >> > > On 04/02/2012 05:40 PM, Joakim

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
Graeme Russ wrote on 2012/04/02 22:59:57: > > > On Apr 3, 2012 6:57 AM, "Joakim Tjernlund" > wrote: > > > > Graeme Russ wrote on 2012/04/02 22:28:46: > > > From: Graeme Russ > > > > > > On 04/02/2012 05:40 PM, Joakim Tjernlund wrote: > > > > Hi Grame > > > > > > > > Graeme Russ wrote on 2012/

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
vapierfil...@gmail.com wrote on 2012/04/02 21:14:14: > > On Mon, Apr 2, 2012 at 14:40, Joakim Tjernlund wrote: > > Marek Vasut wrote on 2012/04/02 20:00:03: > >> Dear Joakim Tjernlund, > >> > Depends, if writing generic code for lots of OS:es you cannot rely > >> > malloc(0). Writing kernel code y

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Graeme Russ
On Apr 3, 2012 6:57 AM, "Joakim Tjernlund" wrote: > > Graeme Russ wrote on 2012/04/02 22:28:46: > > From: Graeme Russ > > > > On 04/02/2012 05:40 PM, Joakim Tjernlund wrote: > > > Hi Grame > > > > > > Graeme Russ wrote on 2012/04/02 09:17:44: > > >> > > >> Hi Joakim, > > >> On Apr 2, 2012 4:55

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
Graeme Russ wrote on 2012/04/02 22:28:46: > From: Graeme Russ > > On 04/02/2012 05:40 PM, Joakim Tjernlund wrote: > > Hi Grame > > > > Graeme Russ wrote on 2012/04/02 09:17:44: > >> > >> Hi Joakim, > >> On Apr 2, 2012 4:55 PM, "Joakim Tjernlund" > >> wrote: > >>> > > Hi Marek, >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Graeme Russ
On 04/02/2012 05:40 PM, Joakim Tjernlund wrote: > Hi Grame > > Graeme Russ wrote on 2012/04/02 09:17:44: >> >> Hi Joakim, >> On Apr 2, 2012 4:55 PM, "Joakim Tjernlund" >> wrote: >>> Hi Marek, On Mon, Apr 2, 2012 at 1:36 PM, Marek Vasut wrote: > Dear Mike Frysinger,

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Marek Vasut
Dear Joakim Tjernlund, > Marek Vasut wrote on 2012/04/02 20:00:03: > > Dear Joakim Tjernlund, > > > > > Marek Vasut wrote on 2012/04/02 18:39:33: > > > > From: Marek Vasut > > > > > > > > Dear Joakim Tjernlund, > > > > > > > > > Marek Vasut wrote on 2012/04/02 17:23:03: > > > > > > Dear Joa

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Mike Frysinger
On Mon, Apr 2, 2012 at 14:40, Joakim Tjernlund wrote: > Marek Vasut wrote on 2012/04/02 20:00:03: >> Dear Joakim Tjernlund, >> > Depends, if writing generic code for lots of OS:es you cannot rely >> > malloc(0). Writing kernel code you can. >> >> No you cannot. It's in the spec you cannot and you

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
Marek Vasut wrote on 2012/04/02 20:00:03: > > Dear Joakim Tjernlund, > > > Marek Vasut wrote on 2012/04/02 18:39:33: > > > From: Marek Vasut > > > > > > Dear Joakim Tjernlund, > > > > > > > Marek Vasut wrote on 2012/04/02 17:23:03: > > > > > Dear Joakim Tjernlund, > > > > > > > > > > > Marek Va

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Marek Vasut
Dear Joakim Tjernlund, > Marek Vasut wrote on 2012/04/02 18:39:33: > > From: Marek Vasut > > > > Dear Joakim Tjernlund, > > > > > Marek Vasut wrote on 2012/04/02 17:23:03: > > > > Dear Joakim Tjernlund, > > > > > > > > > Marek Vasut wrote on 2012/04/02 16:42:30: > > > > > > Dear Joakim Tjer

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
Marek Vasut wrote on 2012/04/02 18:39:33: > From: Marek Vasut > > Dear Joakim Tjernlund, > > > Marek Vasut wrote on 2012/04/02 17:23:03: > > > Dear Joakim Tjernlund, > > > > > > > Marek Vasut wrote on 2012/04/02 16:42:30: > > > > > Dear Joakim Tjernlund, > > > > > > > > > > > Marek Vasut wrot

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Marek Vasut
Dear Joakim Tjernlund, > Marek Vasut wrote on 2012/04/02 17:23:03: > > Dear Joakim Tjernlund, > > > > > Marek Vasut wrote on 2012/04/02 16:42:30: > > > > Dear Joakim Tjernlund, > > > > > > > > > Marek Vasut wrote on 2012/04/02 16:05:13: > > > > > > Dear Joakim Tjernlund, > > > > > > > > > >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
Marek Vasut wrote on 2012/04/02 17:23:03: > > Dear Joakim Tjernlund, > > > Marek Vasut wrote on 2012/04/02 16:42:30: > > > Dear Joakim Tjernlund, > > > > > > > Marek Vasut wrote on 2012/04/02 16:05:13: > > > > > Dear Joakim Tjernlund, > > > > > > > > > > > Hi Grame > > > > > > > > > > > > Graeme

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Marek Vasut
Dear Joakim Tjernlund, > Marek Vasut wrote on 2012/04/02 16:42:30: > > Dear Joakim Tjernlund, > > > > > Marek Vasut wrote on 2012/04/02 16:05:13: > > > > Dear Joakim Tjernlund, > > > > > > > > > Hi Grame > > > > > > > > > > Graeme Russ wrote on 2012/04/02 09:17:44: > > > > > > Hi Joakim, > >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
Marek Vasut wrote on 2012/04/02 16:42:30: > > Dear Joakim Tjernlund, > > > Marek Vasut wrote on 2012/04/02 16:05:13: > > > Dear Joakim Tjernlund, > > > > > > > Hi Grame > > > > > > > > Graeme Russ wrote on 2012/04/02 09:17:44: > > > > > Hi Joakim, > > > > > > > > > > On Apr 2, 2012 4:55 PM, "Joa

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Marek Vasut
Dear Joakim Tjernlund, > Marek Vasut wrote on 2012/04/02 16:05:13: > > Dear Joakim Tjernlund, > > > > > Hi Grame > > > > > > Graeme Russ wrote on 2012/04/02 09:17:44: > > > > Hi Joakim, > > > > > > > > On Apr 2, 2012 4:55 PM, "Joakim Tjernlund" > > > > > > > > wrote: > > > > > > Hi Marek, >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
Marek Vasut wrote on 2012/04/02 16:05:13: > > Dear Joakim Tjernlund, > > > Hi Grame > > > > Graeme Russ wrote on 2012/04/02 09:17:44: > > > Hi Joakim, > > > > > > On Apr 2, 2012 4:55 PM, "Joakim Tjernlund" > wrote: > > > > > Hi Marek, > > > > > > > > > > On Mon, Apr 2, 2012 at 1:36 PM, Marek Vas

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Marek Vasut
Dear Joakim Tjernlund, > Hi Grame > > Graeme Russ wrote on 2012/04/02 09:17:44: > > Hi Joakim, > > > > On Apr 2, 2012 4:55 PM, "Joakim Tjernlund" wrote: > > > > Hi Marek, > > > > > > > > On Mon, Apr 2, 2012 at 1:36 PM, Marek Vasut wrote: > > > > > Dear Mike Frysinger, > > > > > > > > > >>

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Joakim Tjernlund
Hi Grame Graeme Russ wrote on 2012/04/02 09:17:44: > > Hi Joakim, > On Apr 2, 2012 4:55 PM, "Joakim Tjernlund" > wrote: > > > > > > > > Hi Marek, > > > > > > On Mon, Apr 2, 2012 at 1:36 PM, Marek Vasut wrote: > > > > Dear Mike Frysinger, > > > > > > > >> On Sunday 01 April 2012 20:25:44 Graeme

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-02 Thread Graeme Russ
Hi Joakim, On Apr 2, 2012 4:55 PM, "Joakim Tjernlund" wrote: > > > > > Hi Marek, > > > > On Mon, Apr 2, 2012 at 1:36 PM, Marek Vasut wrote: > > > Dear Mike Frysinger, > > > > > >> On Sunday 01 April 2012 20:25:44 Graeme Russ wrote: > > >> > b) The code calling malloc(0) is making a perfectly leg

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Joakim Tjernlund
> > Hi Marek, > > On Mon, Apr 2, 2012 at 1:36 PM, Marek Vasut wrote: > > Dear Mike Frysinger, > > > >> On Sunday 01 April 2012 20:25:44 Graeme Russ wrote: > >> > b) The code calling malloc(0) is making a perfectly legitimate assumption > >> > > >> >    based on how glibc handles malloc(0) > >> > >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Joakim Tjernlund
Graeme Russ wrote on 2012/04/02 05:05:51: > > Hi Marek, > > On Mon, Apr 2, 2012 at 12:51 PM, Marek Vasut wrote: > > Dear Graeme Russ, > > > >> Hi Marek, > > >> Bottom line is, we could do either and we would be 100% compliant with the > >> C standard > >> > >> The question is, what would be more

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Graeme Russ
Hi Marek, On Mon, Apr 2, 2012 at 2:23 PM, Marek Vasut wrote: > Dear Graeme Russ, > >> Hi Marek, >> >> On Mon, Apr 2, 2012 at 1:36 PM, Marek Vasut wrote: >> > Dear Mike Frysinger, >> > >> >> On Sunday 01 April 2012 20:25:44 Graeme Russ wrote: >> >> > b) The code calling malloc(0) is making a perf

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Graeme Russ, > Hi Marek, > > On Mon, Apr 2, 2012 at 1:36 PM, Marek Vasut wrote: > > Dear Mike Frysinger, > > > >> On Sunday 01 April 2012 20:25:44 Graeme Russ wrote: > >> > b) The code calling malloc(0) is making a perfectly legitimate > >> > assumption > >> > > >> >based on how glibc

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Graeme Russ
Hi Marek, On Mon, Apr 2, 2012 at 1:36 PM, Marek Vasut wrote: > Dear Mike Frysinger, > >> On Sunday 01 April 2012 20:25:44 Graeme Russ wrote: >> > b) The code calling malloc(0) is making a perfectly legitimate assumption >> > >> >    based on how glibc handles malloc(0) >> >> not really.  POSIX sa

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Mike Frysinger, > On Sunday 01 April 2012 18:40:05 Graeme Russ wrote: > > if ((long)bytes == 0) { > > > > DEBUG("Warning: malloc of zero block size\n"); > > bytes = 1; > > > > } else if ((long)bytes < 0) { > > > >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Mike Frysinger, > On Sunday 01 April 2012 20:25:44 Graeme Russ wrote: > > b) The code calling malloc(0) is making a perfectly legitimate assumption > > > >based on how glibc handles malloc(0) > > not really. POSIX says malloc(0) is implementation defined (so it may > return a unique ad

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Graeme Russ
Hi Mike, On Mon, Apr 2, 2012 at 1:12 PM, Mike Frysinger wrote: > On Sunday 01 April 2012 20:25:44 Graeme Russ wrote: >> b) The code calling malloc(0) is making a perfectly legitimate assumption >>    based on how glibc handles malloc(0) > > not really.  POSIX says malloc(0) is implementation defi

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Mike Frysinger
On Sunday 01 April 2012 20:25:44 Graeme Russ wrote: > b) The code calling malloc(0) is making a perfectly legitimate assumption >based on how glibc handles malloc(0) not really. POSIX says malloc(0) is implementation defined (so it may return a unique address, or it may return NULL). no use

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Mike Frysinger
On Sunday 01 April 2012 18:40:05 Graeme Russ wrote: > if ((long)bytes == 0) { > DEBUG("Warning: malloc of zero block size\n"); > bytes = 1; > } else if ((long)bytes < 0) { > DEBUG("Error: malloc of negative block size\n"); >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Graeme Russ
Hi Marek, On Mon, Apr 2, 2012 at 12:51 PM, Marek Vasut wrote: > Dear Graeme Russ, > >> Hi Marek, >> Bottom line is, we could do either and we would be 100% compliant with the >> C standard >> >> The question is, what would be more onerous. Since the majority of U-Boot >> developers will be more

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Graeme Russ, > Hi Marek, > > On Mon, Apr 2, 2012 at 11:04 AM, Marek Vasut wrote: > > Dear Graeme Russ, > > > >> Hi Marek, > >> > >> On Mon, Apr 2, 2012 at 10:13 AM, Marek Vasut wrote: > >> > Dear Graeme Russ, > >> > > >> >> Hi Marek, > >> >> > >> >> On Mon, Apr 2, 2012 at 9:45 AM, Mare

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Graeme Russ
Hi Marek, On Mon, Apr 2, 2012 at 11:04 AM, Marek Vasut wrote: > Dear Graeme Russ, > >> Hi Marek, >> >> On Mon, Apr 2, 2012 at 10:13 AM, Marek Vasut wrote: >> > Dear Graeme Russ, >> > >> >> Hi Marek, >> >> >> >> On Mon, Apr 2, 2012 at 9:45 AM, Marek Vasut wrote: >> >> > Dear Graeme Russ, >> >> >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Graeme Russ, > Hi Marek, > > On Mon, Apr 2, 2012 at 10:13 AM, Marek Vasut wrote: > > Dear Graeme Russ, > > > >> Hi Marek, > >> > >> On Mon, Apr 2, 2012 at 9:45 AM, Marek Vasut wrote: > >> > Dear Graeme Russ, > >> > >> Because you just set it off - Right now, that code is assuming malloc

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Graeme Russ
Hi Marek, On Mon, Apr 2, 2012 at 10:13 AM, Marek Vasut wrote: > Dear Graeme Russ, > >> Hi Marek, >> >> On Mon, Apr 2, 2012 at 9:45 AM, Marek Vasut wrote: >> > Dear Graeme Russ, >> > >> Because you just set it off - Right now, that code is assuming malloc(0) >> will return a valid pointer and th

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Graeme Russ, > Hi Marek, > > On Mon, Apr 2, 2012 at 9:45 AM, Marek Vasut wrote: > > Dear Graeme Russ, > > > >> Hi All > >> > >> Here we go again ;) > > > > Yay (polishing my flamethrower)! > > > >> On Mon, Apr 2, 2012 at 12:21 AM, Marek Vasut wrote: > >> > Dear Joakim Tjernlund, > >> >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Graeme Russ
Hi Marek, On Mon, Apr 2, 2012 at 9:45 AM, Marek Vasut wrote: > Dear Graeme Russ, > >> Hi All >> >> Here we go again ;) > > Yay (polishing my flamethrower)! > >> On Mon, Apr 2, 2012 at 12:21 AM, Marek Vasut wrote: >> > Dear Joakim Tjernlund, >> > >> >> Marek Vasut wrote on 2012/04/01 16:01:56: >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Graeme Russ, > Hi All > > Here we go again ;) Yay (polishing my flamethrower)! > On Mon, Apr 2, 2012 at 12:21 AM, Marek Vasut wrote: > > Dear Joakim Tjernlund, > > > >> Marek Vasut wrote on 2012/04/01 16:01:56: > >> > Dear Joakim Tjernlund, > >> > > >> > > > Dear Mike Frysinger, > >> >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Graeme Russ
Hi All Here we go again ;) On Mon, Apr 2, 2012 at 12:21 AM, Marek Vasut wrote: > Dear Joakim Tjernlund, > >> Marek Vasut wrote on 2012/04/01 16:01:56: >> > Dear Joakim Tjernlund, >> > >> > > > Dear Mike Frysinger, >> > > > >> > > > > On Thursday, October 21, 2010 17:10:31 Graeme Russ wrote: >>

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Joakim Tjernlund, > Marek Vasut wrote on 2012/04/01 16:01:56: > > Dear Joakim Tjernlund, > > > > > > Dear Mike Frysinger, > > > > > > > > > On Thursday, October 21, 2010 17:10:31 Graeme Russ wrote: > > > > > > On 22/10/10 06:51, Mike Frysinger wrote: > > > > > > > have u-boot return an err

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Joakim Tjernlund
Marek Vasut wrote on 2012/04/01 16:01:56: > > Dear Joakim Tjernlund, > > > > Dear Mike Frysinger, > > > > > > > On Thursday, October 21, 2010 17:10:31 Graeme Russ wrote: > > > > > On 22/10/10 06:51, Mike Frysinger wrote: > > > > > > have u-boot return an error. > > > > > > > > > > Is NULL what you

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Marek Vasut
Dear Joakim Tjernlund, > > Dear Mike Frysinger, > > > > > On Thursday, October 21, 2010 17:10:31 Graeme Russ wrote: > > > > On 22/10/10 06:51, Mike Frysinger wrote: > > > > > have u-boot return an error. > > > > > > > > Is NULL what you consider to be an error > > > > > > yes > > > > > > > Bes

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-04-01 Thread Joakim Tjernlund
> > Dear Mike Frysinger, > > > On Thursday, October 21, 2010 17:10:31 Graeme Russ wrote: > > > On 22/10/10 06:51, Mike Frysinger wrote: > > > > have u-boot return an error. > > > > > > Is NULL what you consider to be an error > > > > yes > > > > > Besides, is not free(NULL) valid (does nothing) as

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2012-03-31 Thread Marek Vasut
Dear Mike Frysinger, > On Thursday, October 21, 2010 17:10:31 Graeme Russ wrote: > > On 22/10/10 06:51, Mike Frysinger wrote: > > > have u-boot return an error. > > > > Is NULL what you consider to be an error > > yes > > > Besides, is not free(NULL) valid (does nothing) as well? > > yes, free

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-23 Thread Joakim Tjernlund
Scott Wood wrote on 2010/10/22 19:36:33: > > On Fri, 22 Oct 2010 03:55:49 -0400 > Mike Frysinger wrote: > > > On Friday, October 22, 2010 03:37:43 Joakim Tjernlund wrote: > > > Mike Frysinger wrote on 2010/10/22 09:20:22: > > > > On Friday, October 22, 2010 02:10:16 Joakim Tjernlund wrote: > > Yo

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-23 Thread Joakim Tjernlund
Mike Frysinger wrote on 2010/10/22 19:06:14: > > On Friday, October 22, 2010 12:40:07 Joakim Tjernlund wrote: > > Mike Frysinger wrote on 2010/10/22 17:18:05: > > > On Friday, October 22, 2010 04:34:52 Joakim Tjernlund wrote: > > > > Don't you want to know if the app screwed up or if the system is

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Scott Wood
On Fri, 22 Oct 2010 03:55:49 -0400 Mike Frysinger wrote: > On Friday, October 22, 2010 03:37:43 Joakim Tjernlund wrote: > > Mike Frysinger wrote on 2010/10/22 09:20:22: > > > On Friday, October 22, 2010 02:10:16 Joakim Tjernlund wrote: > > > > does not set errno which screws error handling. One h

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Mike Frysinger
On Friday, October 22, 2010 12:40:07 Joakim Tjernlund wrote: > Mike Frysinger wrote on 2010/10/22 17:18:05: > > On Friday, October 22, 2010 04:34:52 Joakim Tjernlund wrote: > > > Don't you want to know if the app screwed up or if the system is out > > > of memory? > > > > > > The only upside to ma

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Joakim Tjernlund
Mike Frysinger wrote on 2010/10/22 17:18:05: > > On Friday, October 22, 2010 04:34:52 Joakim Tjernlund wrote: > > Don't you want to know if the app screwed up or if the system is out > > of memory? > > > > The only upside to malloc(0) == NULL I can see is an extra check > > for apps for which size

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Mike Frysinger
On Friday, October 22, 2010 04:34:52 Joakim Tjernlund wrote: > Don't you want to know if the app screwed up or if the system is out > of memory? > > The only upside to malloc(0) == NULL I can see is an extra check > for apps for which size == 0 is an error to the app too(something the app > should

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Joakim Tjernlund
Mike Frysinger wrote on 2010/10/22 09:55:49: > > On Friday, October 22, 2010 03:37:43 Joakim Tjernlund wrote: > > Mike Frysinger wrote on 2010/10/22 09:20:22: > > > On Friday, October 22, 2010 02:10:16 Joakim Tjernlund wrote: > > > > does not set errno which screws error handling. One have to ben

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Mike Frysinger
On Friday, October 22, 2010 03:37:43 Joakim Tjernlund wrote: > Mike Frysinger wrote on 2010/10/22 09:20:22: > > On Friday, October 22, 2010 02:10:16 Joakim Tjernlund wrote: > > > does not set errno which screws error handling. One have to bend over > > > just to cope with this. > > > > that depend

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Joakim Tjernlund
Reinhard Meyer wrote on 2010/10/22 09:18:02: > > Dear Joakim Tjernlund, > > Mike Frysinger wrote on 2010/10/21 21:51:53: > >> On Thursday, October 21, 2010 07:45:10 Joakim Tjernlund wrote: > >>> Wolfgang Denk wrote on 2010/10/21 13:32:54: > Joakim Tjernlund you wrote: > >> - if ((long)

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Joakim Tjernlund
Mike Frysinger wrote on 2010/10/22 09:20:22: > > On Friday, October 22, 2010 02:10:16 Joakim Tjernlund wrote: > > Mike Frysinger wrote on 2010/10/21 21:51:53: > > > it is useful for malloc(0) == NULL. the glibc behavior is downright > > > obnoxious. we disable this for uClibc and dont see probl

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Mike Frysinger
On Friday, October 22, 2010 02:10:16 Joakim Tjernlund wrote: > Mike Frysinger wrote on 2010/10/21 21:51:53: > > it is useful for malloc(0) == NULL. the glibc behavior is downright > > obnoxious. we disable this for uClibc and dont see problems. if > > anything, we catch accidental programming mi

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-22 Thread Reinhard Meyer
Dear Joakim Tjernlund, > Mike Frysinger wrote on 2010/10/21 21:51:53: >> On Thursday, October 21, 2010 07:45:10 Joakim Tjernlund wrote: >>> Wolfgang Denk wrote on 2010/10/21 13:32:54: Joakim Tjernlund you wrote: >> - if ((long)bytes < 0) return 0; >> + if ((long)bytes <= 0) return 0

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Joakim Tjernlund
Mike Frysinger wrote on 2010/10/21 21:51:53: > > On Thursday, October 21, 2010 07:45:10 Joakim Tjernlund wrote: > > Wolfgang Denk wrote on 2010/10/21 13:32:54: > > > Joakim Tjernlund you wrote: > > > > > - if ((long)bytes < 0) return 0; > > > > > + if ((long)bytes <= 0) return 0; > > > > > > >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Mike Frysinger
On Thursday, October 21, 2010 17:10:31 Graeme Russ wrote: > On 22/10/10 06:51, Mike Frysinger wrote: > > have u-boot return an error. > > Is NULL what you consider to be an error yes > Besides, is not free(NULL) valid (does nothing) as well? yes, free(NULL) should work fine per POSIX -mike si

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Graeme Russ
On 22/10/10 06:51, Mike Frysinger wrote: > On Thursday, October 21, 2010 07:45:10 Joakim Tjernlund wrote: >> Wolfgang Denk wrote on 2010/10/21 13:32:54: >>> Joakim Tjernlund you wrote: > - if ((long)bytes < 0) return 0; > + if ((long)bytes <= 0) return 0; I think you should retu

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Mike Frysinger
On Thursday, October 21, 2010 07:45:10 Joakim Tjernlund wrote: > Wolfgang Denk wrote on 2010/10/21 13:32:54: > > Joakim Tjernlund you wrote: > > > > - if ((long)bytes < 0) return 0; > > > > + if ((long)bytes <= 0) return 0; > > > > > > I think you should return some impossible ptr value =! NULL

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Joakim Tjernlund
Wolfgang Denk wrote on 2010/10/21 14:02:39: > > Dear Joakim Tjernlund, > > In message 0041a...@transmode.se> you wrote: > > > > > Of course we could return some valid pointer like glibc does, i. e. > > > implement something like > > > > > >if (size == 0) > > > size = 8; > > > > > >

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Wolfgang Denk
Dear Joakim Tjernlund, In message you wrote: > > > Of course we could return some valid pointer like glibc does, i. e. > > implement something like > > > >if (size == 0) > > size = 8; > > > > or so. Do you think that would be better? > > Better than NULL, but best would be a ptr t

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Joakim Tjernlund
Wolfgang Denk wrote on 2010/10/21 13:51:26: > > Dear Joakim Tjernlund, > > In message 00408...@transmode.se> you wrote: > > > > > It is legal for malloc() to return NULL in case of size==0, > > > and for the sake of simplicity I recommend we do just that. > > > > Yes, but not very useful. Glib

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Wolfgang Denk
Dear Joakim Tjernlund, In message you wrote: > > > It is legal for malloc() to return NULL in case of size==0, > > and for the sake of simplicity I recommend we do just that. > > Yes, but not very useful. Glibc does not return NULL Maybe not in the current implementation, and not on the archi

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Joakim Tjernlund
Wolfgang Denk wrote on 2010/10/21 13:32:54: > > Dear Joakim Tjernlund, > > In message 003ec...@transmode.se> you wrote: > > > > > - if ((long)bytes < 0) return 0; > > > + if ((long)bytes <= 0) return 0; > > > > I think you should return some impossible ptr value =! NULL > > Size 0 not really

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Wolfgang Denk
Dear Joakim Tjernlund, In message you wrote: > > > - if ((long)bytes < 0) return 0; > > + if ((long)bytes <= 0) return 0; > > I think you should return some impossible ptr value =! NULL > Size 0 not really an error. It is legal for malloc() to return NULL in case of size==0, and for the sa

Re: [U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Joakim Tjernlund
> > In case malloc is invoked with requested size 0, this patch will prevent > the execution of the allocation algorithm (because it corrupts the data > structures) > and will return 0 to the caller. > > Signed-off-by: Nikolaos Kostaras > > --- > common/dlmalloc.c |2 +- > 1 files changed

[U-Boot] [PATCH] Prevent malloc with size 0

2010-10-21 Thread Kostaras Nikolaos
In case malloc is invoked with requested size 0, this patch will prevent the execution of the allocation algorithm (because it corrupts the data structures) and will return 0 to the caller. Signed-off-by: Nikolaos Kostaras --- common/dlmalloc.c |2 +- 1 files changed, 1 insertions(+), 1 de