mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
efi: Use ucs2_as_utf8 in efivarfs instead of open coding a bad version
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 <[email protected]> Acked-by: Matthew Garrett <[email protected]> Tested-by: Lee, Chun-Yi <[email protected]> Signed-off-by: Matt Fleming <[email protected]>
This commit is contained in:
parent
73500267c9
commit
e0d64e6a88
2 changed files with 14 additions and 23 deletions
|
|
@ -118,7 +118,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 = kzalloc(sizeof(*entry), GFP_KERNEL);
|
||||
|
|
@ -128,15 +128,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] = '-';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue