aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hfsplus/dir.c')
-rw-r--r--fs/hfsplus/dir.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index bdec66522de3..fb07d260e692 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -12,6 +12,7 @@
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/random.h> 14#include <linux/random.h>
15#include <linux/nls.h>
15 16
16#include "hfsplus_fs.h" 17#include "hfsplus_fs.h"
17#include "hfsplus_raw.h" 18#include "hfsplus_raw.h"
@@ -127,7 +128,7 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx)
127 struct inode *inode = file_inode(file); 128 struct inode *inode = file_inode(file);
128 struct super_block *sb = inode->i_sb; 129 struct super_block *sb = inode->i_sb;
129 int len, err; 130 int len, err;
130 char strbuf[HFSPLUS_MAX_STRLEN + 1]; 131 char *strbuf;
131 hfsplus_cat_entry entry; 132 hfsplus_cat_entry entry;
132 struct hfs_find_data fd; 133 struct hfs_find_data fd;
133 struct hfsplus_readdir_data *rd; 134 struct hfsplus_readdir_data *rd;
@@ -139,6 +140,11 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx)
139 err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); 140 err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
140 if (err) 141 if (err)
141 return err; 142 return err;
143 strbuf = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_MAX_STRLEN + 1, GFP_KERNEL);
144 if (!strbuf) {
145 err = -ENOMEM;
146 goto out;
147 }
142 hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL); 148 hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
143 err = hfs_brec_find(&fd, hfs_find_rec_by_key); 149 err = hfs_brec_find(&fd, hfs_find_rec_by_key);
144 if (err) 150 if (err)
@@ -193,7 +199,7 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx)
193 hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, 199 hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
194 fd.entrylength); 200 fd.entrylength);
195 type = be16_to_cpu(entry.type); 201 type = be16_to_cpu(entry.type);
196 len = HFSPLUS_MAX_STRLEN; 202 len = NLS_MAX_CHARSET_SIZE * HFSPLUS_MAX_STRLEN;
197 err = hfsplus_uni2asc(sb, &fd.key->cat.name, strbuf, &len); 203 err = hfsplus_uni2asc(sb, &fd.key->cat.name, strbuf, &len);
198 if (err) 204 if (err)
199 goto out; 205 goto out;
@@ -246,6 +252,7 @@ next:
246 } 252 }
247 memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key)); 253 memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key));
248out: 254out:
255 kfree(strbuf);
249 hfs_find_exit(&fd); 256 hfs_find_exit(&fd);
250 return err; 257 return err;
251} 258}