Re: [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM

From: kernel test robot
Date: Wed Dec 04 2024 - 03:30:37 EST


Hi Théo,

kernel test robot noticed the following build errors:

[auto build test ERROR on 40384c840ea1944d7c5a392e8975ed088ecf0b37]

url: https://github.com/intel-lab-lkp/linux/commits/Th-o-Lebrun/dt-bindings-nvmem-rmem-Add-mobileye-eyeq5-bootloader-config/20241204-103417
base: 40384c840ea1944d7c5a392e8975ed088ecf0b37
patch link: https://lore.kernel.org/r/20241203-rmem-v1-5-24f4970cf14e%40bootlin.com
patch subject: [PATCH 5/6] nvmem: rmem: add CRC validation for Mobileye EyeQ5 NVMEM
config: arc-randconfig-001 (https://download.01.org/0day-ci/archive/20241204/202412041614.WGhDRXyh-lkp@xxxxxxxxx/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241204/202412041614.WGhDRXyh-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412041614.WGhDRXyh-lkp@xxxxxxxxx/

All error/warnings (new ones prefixed by >>):

drivers/nvmem/rmem.c: In function 'rmem_eyeq5_checksum':
>> drivers/nvmem/rmem.c:66:9: error: cleanup argument not a function
66 | void *buf __free(kfree) = NULL;
| ^~~~
>> drivers/nvmem/rmem.c:97:15: error: implicit declaration of function 'kmalloc'; did you mean 'mm_alloc'? [-Werror=implicit-function-declaration]
97 | buf = kmalloc(header.size, GFP_KERNEL);
| ^~~~~~~
| mm_alloc
>> drivers/nvmem/rmem.c:97:13: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
97 | buf = kmalloc(header.size, GFP_KERNEL);
| ^
cc1: some warnings being treated as errors


vim +66 drivers/nvmem/rmem.c

62
63 static int rmem_eyeq5_checksum(struct rmem *priv)
64 {
65 struct rmem_eyeq5_header header;
> 66 void *buf __free(kfree) = NULL;
67 u32 computed_crc, *target_crc;
68 size_t data_size;
69 int ret;
70
71 ret = rmem_read(priv, 0, &header, sizeof(header));
72 if (ret)
73 return ret;
74
75 if (header.magic != RMEM_EYEQ5_MAGIC)
76 return -EINVAL;
77
78 /*
79 * Avoid massive kmalloc() if header read is invalid;
80 * the check would be done by the next rmem_read() anyway.
81 */
82 if (header.size > priv->mem->size)
83 return -EINVAL;
84
85 /*
86 * 0 +-------------------+
87 * | Header (12 bytes) | \
88 * +-------------------+ |
89 * | | | data to be CRCed
90 * | ... | |
91 * | | /
92 * data_size +-------------------+
93 * | CRC (4 bytes) |
94 * header.size +-------------------+
95 */
96
> 97 buf = kmalloc(header.size, GFP_KERNEL);
98 if (!buf)
99 return -ENOMEM;
100
101 ret = rmem_read(priv, 0, buf, header.size);
102 if (ret)
103 return ret;
104
105 data_size = header.size - sizeof(*target_crc);
106 target_crc = buf + data_size;
107 computed_crc = crc32(U32_MAX, buf, data_size) ^ U32_MAX;
108
109 if (computed_crc == *target_crc)
110 return 0;
111
112 dev_err(priv->dev,
113 "checksum failed: computed %#x, expected %#x, header (%#x, %#x, %#x)\n",
114 computed_crc, *target_crc, header.magic, header.version, header.size);
115 return -EINVAL;
116 }
117

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki