aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorMarcin Slusarz <marcin.slusarz@gmail.com>2008-11-16 13:02:45 -0500
committerJan Kara <jack@suse.cz>2009-04-02 06:29:49 -0400
commit530f1a5e3e93a038a457faf716975ed19f82831d (patch)
tree59dbd8517dd925067891d61b26589ad759c56278 /fs/udf
parentba9aadd80c24775e55a93ebe0c2491b4d2899257 (diff)
udf: reduce stack usage of udf_get_filename
Allocate strings with kmalloc. Checkstack output: Before: udf_get_filename: 600 After: udf_get_filename: 136 Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/unicode.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 9fdf8c93c58e..a3bbdbde9f4b 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -324,34 +324,43 @@ try_again:
324int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, 324int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
325 int flen) 325 int flen)
326{ 326{
327 struct ustr filename, unifilename; 327 struct ustr *filename, *unifilename;
328 int len; 328 int len = 0;
329 329
330 if (udf_build_ustr_exact(&unifilename, sname, flen)) 330 filename = kmalloc(sizeof(struct ustr), GFP_NOFS);
331 if (!filename)
331 return 0; 332 return 0;
332 333
334 unifilename = kmalloc(sizeof(struct ustr), GFP_NOFS);
335 if (!unifilename)
336 goto out1;
337
338 if (udf_build_ustr_exact(unifilename, sname, flen))
339 goto out2;
340
333 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { 341 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
334 if (!udf_CS0toUTF8(&filename, &unifilename)) { 342 if (!udf_CS0toUTF8(filename, unifilename)) {
335 udf_debug("Failed in udf_get_filename: sname = %s\n", 343 udf_debug("Failed in udf_get_filename: sname = %s\n",
336 sname); 344 sname);
337 return 0; 345 goto out2;
338 } 346 }
339 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { 347 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
340 if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, 348 if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename,
341 &unifilename)) { 349 unifilename)) {
342 udf_debug("Failed in udf_get_filename: sname = %s\n", 350 udf_debug("Failed in udf_get_filename: sname = %s\n",
343 sname); 351 sname);
344 return 0; 352 goto out2;
345 } 353 }
346 } else 354 } else
347 return 0; 355 goto out2;
348 356
349 len = udf_translate_to_linux(dname, filename.u_name, filename.u_len, 357 len = udf_translate_to_linux(dname, filename->u_name, filename->u_len,
350 unifilename.u_name, unifilename.u_len); 358 unifilename->u_name, unifilename->u_len);
351 if (len) 359out2:
352 return len; 360 kfree(unifilename);
353 361out1:
354 return 0; 362 kfree(filename);
363 return len;
355} 364}
356 365
357int udf_put_filename(struct super_block *sb, const uint8_t *sname, 366int udf_put_filename(struct super_block *sb, const uint8_t *sname,