diff --git a/nls.c b/nls.c index 675d0e7058c5..58e434a5c330 100644 --- a/nls.c +++ b/nls.c @@ -3,9 +3,13 @@ * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd. */ +#include #include #include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) +#include +#endif #include #include "exfat_raw.h" @@ -659,7 +663,11 @@ static int exfat_load_upcase_table(struct super_block *sb, unsigned char skip = false; unsigned short *upcase_table; - upcase_table = kcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) + upcase_table = kvcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); +#else + upcase_table = vzalloc(UTBL_COUNT * sizeof(unsigned short)); +#endif if (!upcase_table) return -ENOMEM; @@ -715,7 +723,11 @@ static int exfat_load_default_upcase_table(struct super_block *sb) unsigned short uni = 0, *upcase_table; unsigned int index = 0; - upcase_table = kcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) + upcase_table = kvcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); +#else + upcase_table = vzalloc(UTBL_COUNT * sizeof(unsigned short)); +#endif if (!upcase_table) return -ENOMEM; @@ -803,5 +815,9 @@ int exfat_create_upcase_table(struct super_block *sb) void exfat_free_upcase_table(struct exfat_sb_info *sbi) { - kfree(sbi->vol_utbl); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) + kvfree(sbi->vol_utbl); +#else + vfree(sbi->vol_utbl); +#endif }