Re: [PATCH] params: fix potential memory leak in add_sysfs_param()

2014-08-20 Thread Arjun Sreedharan
On 21 August 2014 03:47, Woodhouse, David wrote: > On Thu, 2014-08-21 at 07:35 +0930, Rusty Russell wrote: >> >> Above this: >> if (!mk->mp) { >> num = 0; >> attrs = NULL; >> } else { >> num = mk->mp->num; >> attrs = m

Re: [PATCH] params: fix potential memory leak in add_sysfs_param()

2014-08-20 Thread David Woodhouse
On Wed, 2014-08-20 at 22:17 +, Woodhouse, David wrote: > > Except that in the failure case we *free* the old mk->mp and never free > mk->mp->grp.attrs so it *is* indeed lost. > > A simpler version of Arjun's patch might look like this: > > diff --git a/kernel/params.c b/kernel/params.c > ind

Re: [PATCH] params: fix potential memory leak in add_sysfs_param()

2014-08-20 Thread Woodhouse, David
On Thu, 2014-08-21 at 07:35 +0930, Rusty Russell wrote: > > Above this: > if (!mk->mp) { > num = 0; > attrs = NULL; > } else { > num = mk->mp->num; > attrs = mk->mp->grp.attrs; > } > > So, attrs is just a temp

Re: [PATCH] params: fix potential memory leak in add_sysfs_param()

2014-08-20 Thread Rusty Russell
Arjun Sreedharan writes: > On 21 August 2014 02:19, Rusty Russell wrote: >> Arjun Sreedharan writes: >>> Do not leak memory when attrs is non NULL and >>> krealloc() fails. Without temporary variable, >>> reference to it is lost. >>> >>> Signed-off-by: Arjun Sreedharan >> >> ... >> >>> }

Re: [PATCH] params: fix potential memory leak in add_sysfs_param()

2014-08-20 Thread Woodhouse, David
On Thu, 2014-08-21 at 06:19 +0930, Rusty Russell wrote: > Arjun Sreedharan writes: > > Do not leak memory when attrs is non NULL and > > krealloc() fails. Without temporary variable, > > reference to it is lost. > > > > Signed-off-by: Arjun Sreedharan > > ... > > > } > > - /* Despite look

Re: [PATCH] params: fix potential memory leak in add_sysfs_param()

2014-08-20 Thread Arjun Sreedharan
On 21 August 2014 02:19, Rusty Russell wrote: > Arjun Sreedharan writes: >> Do not leak memory when attrs is non NULL and >> krealloc() fails. Without temporary variable, >> reference to it is lost. >> >> Signed-off-by: Arjun Sreedharan > > ... > >> } >> - /* Despite looking like the t

Re: [PATCH] params: fix potential memory leak in add_sysfs_param()

2014-08-20 Thread Rusty Russell
Arjun Sreedharan writes: > Do not leak memory when attrs is non NULL and > krealloc() fails. Without temporary variable, > reference to it is lost. > > Signed-off-by: Arjun Sreedharan ... > } > - /* Despite looking like the typical realloc() bug, this is safe. > - * We *want* the

[PATCH] params: fix potential memory leak in add_sysfs_param()

2014-08-20 Thread Arjun Sreedharan
Do not leak memory when attrs is non NULL and krealloc() fails. Without temporary variable, reference to it is lost. Signed-off-by: Arjun Sreedharan --- kernel/params.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/params.c b/kernel/params.c index 34

[PATCH] params: Fix potential memory leak in add_sysfs_param()

2013-03-14 Thread David Woodhouse
On allocation failure, it would fail to free the old attrs array which was no longer referenced by anything (since it would free the old module_param_attrs struct on the way out). Comment the suspicious-looking krealloc() usage to explain why it *isn't* actually buggy, despite looking like a class