Skip to contentSkip to conversation

reiserfs: Use kstrdup instead of kmalloc/strcpy

PATCH In review Ionut-Gabriel Radu 2 participants 2 messages Mar 10, 2013 – Mar 11, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 reiserfs: Use kstrdup instead of kmalloc/strcpy

---
 fs/reiserfs/super.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/reiserfs/super.c +1 -3
index 194113b..f8a23c3 100644
@@ -1147,8 +1147,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options,	/* strin
 							 "on filesystem root.");
 					return 0;
 				}
-				qf_names[qtype] =
-				    kmalloc(strlen(arg) + 1, GFP_KERNEL);
+				qf_names[qtype] = kstrdup(arg, GFP_KERNEL);
 				if (!qf_names[qtype]) {
 					reiserfs_warning(s, "reiserfs-2502",
 							 "not enough memory "
@@ -1156,7 +1155,6 @@ static int reiserfs_parse_options(struct super_block *s, char *options,	/* strin
 							 "quotafile name.");
 					return 0;
 				}
-				strcpy(qf_names[qtype], arg);
 				if (qtype == USRQUOTA)
 					*mount_options |= 1 << REISERFS_USRQUOTA;
 				else
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 1 line · Ionut-Gabriel Radu

Thanks. Added to my tree.

Honza

Quoted 29 lines
---
 fs/reiserfs/super.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/reiserfs/super.c +1 -3
index 194113b..f8a23c3 100644
@@ -1147,8 +1147,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options,	/* strin
 							 "on filesystem root.");
 					return 0;
 				}
-				qf_names[qtype] =
-				    kmalloc(strlen(arg) + 1, GFP_KERNEL);
+				qf_names[qtype] = kstrdup(arg, GFP_KERNEL);
 				if (!qf_names[qtype]) {
 					reiserfs_warning(s, "reiserfs-2502",
 							 "not enough memory "
@@ -1156,7 +1155,6 @@ static int reiserfs_parse_options(struct super_block *s, char *options,	/* strin
 							 "quotafile name.");
 					return 0;
 				}
-				strcpy(qf_names[qtype], arg);
 				if (qtype == USRQUOTA)
 					*mount_options |= 1 << REISERFS_USRQUOTA;
 				else
Signature · 1 line
1.7.10.4
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR