summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2016-02-08 14:48:12 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-03-16 08:41:37 -0700
commitc6d535a35f5a3e842e02d13f84a729ef98f20952 (patch)
treeec3aa6a1a3dd6680fdae05191d08cf261fe6983f /fs
parentf0b5aae480e53e26c0739241144eaa0e2e56a4fc (diff)
downloadlwn-c6d535a35f5a3e842e02d13f84a729ef98f20952.tar.gz
lwn-c6d535a35f5a3e842e02d13f84a729ef98f20952.zip
efi: Use ucs2_as_utf8 in efivarfs instead of open coding a bad version
commit e0d64e6a880e64545ad7d55786aa84ab76bac475 upstream. Translate EFI's UCS-2 variable names to UTF-8 instead of just assuming all variable names fit in ASCII. Signed-off-by: Peter Jones <pjones@redhat.com> Acked-by: Matthew Garrett <mjg59@coreos.com> Tested-by: Lee, Chun-Yi <jlee@suse.com> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/efivarfs/super.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 141aee31884f..9ca5c5ee0038 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -128,7 +128,7 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
struct dentry *dentry, *root = sb->s_root;
unsigned long size = 0;
char *name;
- int len, i;
+ int len;
int err = -ENOMEM;
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
@@ -138,15 +138,14 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
memcpy(entry->var.VariableName, name16, name_size);
memcpy(&(entry->var.VendorGuid), &vendor, sizeof(efi_guid_t));
- len = ucs2_strlen(entry->var.VariableName);
+ len = ucs2_utf8size(entry->var.VariableName);
/* name, plus '-', plus GUID, plus NUL*/
name = kmalloc(len + 1 + EFI_VARIABLE_GUID_LEN + 1, GFP_KERNEL);
if (!name)
goto fail;
- for (i = 0; i < len; i++)
- name[i] = entry->var.VariableName[i] & 0xFF;
+ ucs2_as_utf8(name, entry->var.VariableName, len);
name[len] = '-';