summaryrefslogtreecommitdiff
path: root/fs/udf/unicode.c
diff options
context:
space:
mode:
authorFabian Frederick <fabf@skynet.be>2015-04-08 21:23:51 +0200
committerJan Kara <jack@suse.cz>2015-05-18 11:23:03 +0200
commit5ceb8b554dcaaf6844415cd2616ce2e0132530fa (patch)
treec80877de890e6f3ab8d47aae705d39401031efb8 /fs/udf/unicode.c
parentc0655fe9b0901a968800f56687be3c62b4cce5d2 (diff)
udf: Return -ENOMEM when allocation fails in udf_get_filename()
Return -ENOMEM when allocation fails in udf_get_filename(). Update udf_pc_to_char(), udf_readdir(), and udf_find_entry() to handle the error appropriately. This allows us to pass appropriate error to userspace instead of corrupting symlink contents by omitting some path elements. Signed-off-by: Fabian Frederick <fabf@skynet.be> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/unicode.c')
-rw-r--r--fs/udf/unicode.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index b84fee372734..4911c1d84882 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -338,15 +338,17 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
uint8_t *dname, int dlen)
{
struct ustr *filename, *unifilename;
- int len = 0;
+ int ret = 0;
filename = kmalloc(sizeof(struct ustr), GFP_NOFS);
if (!filename)
- return 0;
+ return -ENOMEM;
unifilename = kmalloc(sizeof(struct ustr), GFP_NOFS);
- if (!unifilename)
+ if (!unifilename) {
+ ret = -ENOMEM;
goto out1;
+ }
if (udf_build_ustr_exact(unifilename, sname, slen))
goto out2;
@@ -367,14 +369,14 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
} else
goto out2;
- len = udf_translate_to_linux(dname, dlen,
+ ret = udf_translate_to_linux(dname, dlen,
filename->u_name, filename->u_len,
unifilename->u_name, unifilename->u_len);
out2:
kfree(unifilename);
out1:
kfree(filename);
- return len;
+ return ret;
}
int udf_put_filename(struct super_block *sb, const uint8_t *sname,