From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7446202118235973712==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: Re: [PATCH] drivers/firewire: use struct_size over open coded arithmetic Date: Fri, 28 Jan 2022 22:54:14 +0800 Message-ID: <202201282234.A43HZoSH-lkp@intel.com> In-Reply-To: <20220128080336.1211525-1-chi.minghao@zte.com.cn> List-Id: --===============7446202118235973712== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi, Thank you for the patch! Yet something to improve: [auto build test ERROR on ieee1394-linux1394/for-next] [also build test ERROR on v5.17-rc1 next-20220128] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/drivers= -firewire-use-struct_size-over-open-coded-arithmetic/20220128-160602 base: https://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.= git for-next config: arm-randconfig-c002-20220124 (https://download.01.org/0day-ci/archi= ve/20220128/202201282234.A43HZoSH-lkp(a)intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0 reproduce (this is a W=3D1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/= make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/1567c3f747219c35e83d9c1f4= ac3c3d36f447d90 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review cgel-zte-gmail-com/drivers-firewir= e-use-struct_size-over-open-coded-arithmetic/20220128-160602 git checkout 1567c3f747219c35e83d9c1f4ac3c3d36f447d90 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dgcc-11.2.0 make.cross= O=3Dbuild_dir ARCH=3Darm SHELL=3D/bin/bash drivers/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): In file included from include/linux/device.h:29, from drivers/firewire/core-transaction.c:10: drivers/firewire/core-transaction.c: In function 'allocate_request': >> include/linux/overflow.h:326:32: error: invalid type argument of '->' (h= ave 'struct fw_request') 326 | sizeof(*(p)->member) + __must_be_array((p)->= member),\ | ^~ drivers/firewire/core-transaction.c:780:27: note: in expansion of macro = 'struct_size' 780 | request =3D kmalloc(struct_size(*request, data, length),= GFP_ATOMIC); | ^~~~~~~~~~~ In file included from include/linux/bits.h:22, from include/linux/bitops.h:6, from include/linux/kernel.h:12, from include/asm-generic/bug.h:20, from arch/arm/include/asm/bug.h:60, from include/linux/bug.h:5, from drivers/firewire/core-transaction.c:8: include/linux/overflow.h:326:63: error: invalid type argument of '->' (h= ave 'struct fw_request') 326 | sizeof(*(p)->member) + __must_be_array((p)->= member),\ | ^~ include/linux/build_bug.h:16:62: note: in definition of macro 'BUILD_BUG= _ON_ZERO' 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e))= ; }))) | ^ include/linux/compiler.h:240:51: note: in expansion of macro '__same_typ= e' 240 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a= ), &(a)[0])) | ^~~~~~~~~~~ include/linux/overflow.h:326:44: note: in expansion of macro '__must_be_= array' 326 | sizeof(*(p)->member) + __must_be_array((p)->= member),\ | ^~~~~~~~~~~~~~~ drivers/firewire/core-transaction.c:780:27: note: in expansion of macro = 'struct_size' 780 | request =3D kmalloc(struct_size(*request, data, length),= GFP_ATOMIC); | ^~~~~~~~~~~ include/linux/overflow.h:326:63: error: invalid type argument of '->' (h= ave 'struct fw_request') 326 | sizeof(*(p)->member) + __must_be_array((p)->= member),\ | ^~ include/linux/build_bug.h:16:62: note: in definition of macro 'BUILD_BUG= _ON_ZERO' 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e))= ; }))) | ^ include/linux/compiler.h:240:51: note: in expansion of macro '__same_typ= e' 240 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a= ), &(a)[0])) | ^~~~~~~~~~~ include/linux/overflow.h:326:44: note: in expansion of macro '__must_be_= array' 326 | sizeof(*(p)->member) + __must_be_array((p)->= member),\ | ^~~~~~~~~~~~~~~ drivers/firewire/core-transaction.c:780:27: note: in expansion of macro = 'struct_size' 780 | request =3D kmalloc(struct_size(*request, data, length),= GFP_ATOMIC); | ^~~~~~~~~~~ include/linux/build_bug.h:16:51: error: bit-field '' width no= t an integer constant 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e))= ; }))) | ^ include/linux/compiler.h:240:33: note: in expansion of macro 'BUILD_BUG_= ON_ZERO' 240 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a= ), &(a)[0])) | ^~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:44: note: in expansion of macro '__must_be_= array' 326 | sizeof(*(p)->member) + __must_be_array((p)->= member),\ | ^~~~~~~~~~~~~~~ drivers/firewire/core-transaction.c:780:27: note: in expansion of macro = 'struct_size' 780 | request =3D kmalloc(struct_size(*request, data, length),= GFP_ATOMIC); | ^~~~~~~~~~~ In file included from include/linux/device.h:29, from drivers/firewire/core-transaction.c:10: >> include/linux/overflow.h:327:28: error: invalid type argument of unary '= *' (have 'struct fw_request') 327 | sizeof(*(p))) | ^~~~ drivers/firewire/core-transaction.c:780:27: note: in expansion of macro = 'struct_size' 780 | request =3D kmalloc(struct_size(*request, data, length),= GFP_ATOMIC); | ^~~~~~~~~~~ vim +326 include/linux/overflow.h 610b15c50e86eb1 Kees Cook 2018-05-07 312 = 610b15c50e86eb1 Kees Cook 2018-05-07 313 /** 610b15c50e86eb1 Kees Cook 2018-05-07 314 * struct_size() - Cal= culate size of structure with trailing array. 610b15c50e86eb1 Kees Cook 2018-05-07 315 * @p: Pointer to the = structure. 610b15c50e86eb1 Kees Cook 2018-05-07 316 * @member: Name of th= e array member. b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 317 * @count: Number of e= lements in the array. 610b15c50e86eb1 Kees Cook 2018-05-07 318 * 610b15c50e86eb1 Kees Cook 2018-05-07 319 * Calculates size of = memory needed for structure @p followed by an b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 320 * array of @count num= ber of @member elements. 610b15c50e86eb1 Kees Cook 2018-05-07 321 * 610b15c50e86eb1 Kees Cook 2018-05-07 322 * Return: number of b= ytes needed or SIZE_MAX on overflow. 610b15c50e86eb1 Kees Cook 2018-05-07 323 */ b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 324 #define struct_size(p,= member, count) \ b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 325 __ab_c_size(count, = \ 610b15c50e86eb1 Kees Cook 2018-05-07 @326 sizeof(*(p)->mem= ber) + __must_be_array((p)->member),\ 610b15c50e86eb1 Kees Cook 2018-05-07 @327 sizeof(*(p))) 610b15c50e86eb1 Kees Cook 2018-05-07 328 = --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============7446202118235973712==--