reiserfs-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] reiserfs: kstrdup() memory handling
@ 2015-03-21 17:00 Sanidhya Kashyap
  2015-03-21 17:15 ` Josh Triplett
  0 siblings, 1 reply; 4+ messages in thread
From: Sanidhya Kashyap @ 2015-03-21 17:00 UTC (permalink / raw)
  To: jack, jeffm, akpm, fabf, josh, rashika.kheria, reiserfs-devel,
	linux-kernel
  Cc: taesoo, changwoo, sanidhya, blee, Sanidhya Kashyap

Checking for ENOMEM even for new_opts in reiserfs_remount function as
there is a possibility of nothing being allocated.

Signed-off-by: Sanidhya Kashyap <sanidhya.gatech@gmail.com>
---
 fs/reiserfs/super.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 71fbbe3..bf9bc66 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1397,6 +1397,11 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
 	int i;
 #endif
 
+	if (!new_opts) {
+		err = -ENOMEM;
+		goto out_err_no_kfree;
+	}
+
 	sync_filesystem(s);
 	reiserfs_write_lock(s);
 
@@ -1549,6 +1554,7 @@ out_err_unlock:
 	reiserfs_write_unlock(s);
 out_err:
 	kfree(new_opts);
+out_err_no_kfree:
 	return err;
 }
 
-- 
2.1.0

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

* Re: [PATCH] reiserfs: kstrdup() memory handling
  2015-03-21 17:00 [PATCH] reiserfs: kstrdup() memory handling Sanidhya Kashyap
@ 2015-03-21 17:15 ` Josh Triplett
  2015-03-23  0:12   ` Sanidhya Kashyap
  0 siblings, 1 reply; 4+ messages in thread
From: Josh Triplett @ 2015-03-21 17:15 UTC (permalink / raw)
  To: Sanidhya Kashyap
  Cc: jack, jeffm, akpm, fabf, rashika.kheria, reiserfs-devel,
	linux-kernel, taesoo, changwoo, sanidhya, blee

On Sat, Mar 21, 2015 at 01:00:13PM -0400, Sanidhya Kashyap wrote:
> Checking for ENOMEM even for new_opts in reiserfs_remount function as
> there is a possibility of nothing being allocated.

You don't need to add a new label; kfree(NULL) is a no-op.

> Signed-off-by: Sanidhya Kashyap <sanidhya.gatech@gmail.com>
> ---
>  fs/reiserfs/super.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
> index 71fbbe3..bf9bc66 100644
> --- a/fs/reiserfs/super.c
> +++ b/fs/reiserfs/super.c
> @@ -1397,6 +1397,11 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
>  	int i;
>  #endif
>  
> +	if (!new_opts) {
> +		err = -ENOMEM;
> +		goto out_err_no_kfree;
> +	}
> +
>  	sync_filesystem(s);
>  	reiserfs_write_lock(s);
>  
> @@ -1549,6 +1554,7 @@ out_err_unlock:
>  	reiserfs_write_unlock(s);
>  out_err:
>  	kfree(new_opts);
> +out_err_no_kfree:
>  	return err;
>  }
>  
> -- 
> 2.1.0
> 

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

* Re: [PATCH] reiserfs: kstrdup() memory handling
  2015-03-21 17:15 ` Josh Triplett
@ 2015-03-23  0:12   ` Sanidhya Kashyap
  2015-03-23  2:55     ` Josh Triplett
  0 siblings, 1 reply; 4+ messages in thread
From: Sanidhya Kashyap @ 2015-03-23  0:12 UTC (permalink / raw)
  To: Josh Triplett; +Cc: reiserfs-devel, linux-kernel, Kashyap, Sanidhya

On Sat, Mar 21, 2015 at 1:15 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> On Sat, Mar 21, 2015 at 01:00:13PM -0400, Sanidhya Kashyap wrote:
>> Checking for ENOMEM even for new_opts in reiserfs_remount function as
>> there is a possibility of nothing being allocated.
>
> You don't need to add a new label; kfree(NULL) is a no-op.
>

Shall I resubmit the patch?

Thanks,
Sanidhya

>> Signed-off-by: Sanidhya Kashyap <sanidhya.gatech@gmail.com>
>> ---
>>  fs/reiserfs/super.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
>> index 71fbbe3..bf9bc66 100644
>> --- a/fs/reiserfs/super.c
>> +++ b/fs/reiserfs/super.c
>> @@ -1397,6 +1397,11 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
>>       int i;
>>  #endif
>>
>> +     if (!new_opts) {
>> +             err = -ENOMEM;
>> +             goto out_err_no_kfree;
>> +     }
>> +
>>       sync_filesystem(s);
>>       reiserfs_write_lock(s);
>>
>> @@ -1549,6 +1554,7 @@ out_err_unlock:
>>       reiserfs_write_unlock(s);
>>  out_err:
>>       kfree(new_opts);
>> +out_err_no_kfree:
>>       return err;
>>  }
>>
>> --
>> 2.1.0
>>

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

* Re: [PATCH] reiserfs: kstrdup() memory handling
  2015-03-23  0:12   ` Sanidhya Kashyap
@ 2015-03-23  2:55     ` Josh Triplett
  0 siblings, 0 replies; 4+ messages in thread
From: Josh Triplett @ 2015-03-23  2:55 UTC (permalink / raw)
  To: Sanidhya Kashyap; +Cc: reiserfs-devel, linux-kernel, Kashyap, Sanidhya

On Sun, Mar 22, 2015 at 08:12:46PM -0400, Sanidhya Kashyap wrote:
> On Sat, Mar 21, 2015 at 1:15 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> > On Sat, Mar 21, 2015 at 01:00:13PM -0400, Sanidhya Kashyap wrote:
> >> Checking for ENOMEM even for new_opts in reiserfs_remount function as
> >> there is a possibility of nothing being allocated.
> >
> > You don't need to add a new label; kfree(NULL) is a no-op.
> >
> 
> Shall I resubmit the patch?

I would suggest doing so, yes, after you see if anyone else has feedback
on it.

- Josh Triplett

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

end of thread, other threads:[~2015-03-23  2:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-21 17:00 [PATCH] reiserfs: kstrdup() memory handling Sanidhya Kashyap
2015-03-21 17:15 ` Josh Triplett
2015-03-23  0:12   ` Sanidhya Kashyap
2015-03-23  2:55     ` Josh Triplett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).