|
3 | 3 | * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
|
4 | 4 | */
|
5 | 5 |
|
| 6 | +#include <linux/version.h> |
6 | 7 | #include <linux/string.h>
|
7 | 8 | #include <linux/slab.h>
|
8 | 9 | #include <linux/buffer_head.h>
|
| 10 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) |
| 11 | +#include <linux/vmalloc.h> |
| 12 | +#endif |
9 | 13 | #include <asm/unaligned.h>
|
10 | 14 |
|
11 | 15 | #include "exfat_raw.h"
|
@@ -659,7 +663,11 @@ static int exfat_load_upcase_table(struct super_block *sb,
|
659 | 663 | unsigned char skip = false;
|
660 | 664 | unsigned short *upcase_table;
|
661 | 665 |
|
662 |
| - upcase_table = kcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); |
| 666 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) |
| 667 | + upcase_table = kvcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); |
| 668 | +#else |
| 669 | + upcase_table = vzalloc(UTBL_COUNT * sizeof(unsigned short)); |
| 670 | +#endif |
663 | 671 | if (!upcase_table)
|
664 | 672 | return -ENOMEM;
|
665 | 673 |
|
@@ -715,7 +723,11 @@ static int exfat_load_default_upcase_table(struct super_block *sb)
|
715 | 723 | unsigned short uni = 0, *upcase_table;
|
716 | 724 | unsigned int index = 0;
|
717 | 725 |
|
718 |
| - upcase_table = kcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); |
| 726 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) |
| 727 | + upcase_table = kvcalloc(UTBL_COUNT, sizeof(unsigned short), GFP_KERNEL); |
| 728 | +#else |
| 729 | + upcase_table = vzalloc(UTBL_COUNT * sizeof(unsigned short)); |
| 730 | +#endif |
719 | 731 | if (!upcase_table)
|
720 | 732 | return -ENOMEM;
|
721 | 733 |
|
@@ -803,5 +815,9 @@ int exfat_create_upcase_table(struct super_block *sb)
|
803 | 815 |
|
804 | 816 | void exfat_free_upcase_table(struct exfat_sb_info *sbi)
|
805 | 817 | {
|
806 |
| - kfree(sbi->vol_utbl); |
| 818 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) |
| 819 | + kvfree(sbi->vol_utbl); |
| 820 | +#else |
| 821 | + vfree(sbi->vol_utbl); |
| 822 | +#endif |
807 | 823 | }
|
0 commit comments