* [PATCH] drivers/firewire: use struct_size over open coded arithmetic
@ 2022-01-28 8:03 cgel.zte
2022-01-28 12:08 ` kernel test robot
2022-01-28 14:54 ` kernel test robot
0 siblings, 2 replies; 5+ messages in thread
From: cgel.zte @ 2022-01-28 8:03 UTC (permalink / raw)
To: stefanr; +Cc: linux1394-devel, linux-kernel, Minghao Chi, Zeal Robot
From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
Replace zero-length array with flexible-array member and make use
of the struct_size() helper in kmalloc(). For example:
struct fw_request {
...
u32 data[];
}
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
---
drivers/firewire/core-transaction.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index ac487c96bb71..2e9dd988ed0e 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -777,7 +777,7 @@ static struct fw_request *allocate_request(struct fw_card *card,
return NULL;
}
- request = kmalloc(sizeof(*request) + length, GFP_ATOMIC);
+ request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC);
if (request == NULL)
return NULL;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] drivers/firewire: use struct_size over open coded arithmetic 2022-01-28 8:03 [PATCH] drivers/firewire: use struct_size over open coded arithmetic cgel.zte @ 2022-01-28 12:08 ` kernel test robot 2022-01-28 14:54 ` kernel test robot 1 sibling, 0 replies; 5+ messages in thread From: kernel test robot @ 2022-01-28 12:08 UTC (permalink / raw) To: cgel.zte, stefanr Cc: llvm, kbuild-all, linux1394-devel, linux-kernel, Minghao Chi, Zeal Robot 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: hexagon-randconfig-r015-20220128 (https://download.01.org/0day-ci/archive/20220128/202201282044.Ye1mhIOd-lkp@intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 33b45ee44b1f32ffdbc995e6fec806271b4b3ba4) reproduce (this is a W=1 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/1567c3f747219c35e83d9c1f4ac3c3d36f447d90 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review cgel-zte-gmail-com/drivers-firewire-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=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/firewire/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/firewire/core-transaction.c:780:20: error: member reference type 'struct fw_request' is not a pointer; did you mean to use '.'? request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:18: note: expanded from macro 'struct_size' sizeof(*(p)->member) + __must_be_array((p)->member),\ ~~~^ >> drivers/firewire/core-transaction.c:780:20: error: indirection requires pointer operand ('u32[]' (aka 'unsigned int[]') invalid) request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:14: note: expanded from macro 'struct_size' sizeof(*(p)->member) + __must_be_array((p)->member),\ ^~~~~~~~~~~~ >> drivers/firewire/core-transaction.c:780:20: error: member reference type 'struct fw_request' is not a pointer; did you mean to use '.'? request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:49: note: expanded from macro 'struct_size' sizeof(*(p)->member) + __must_be_array((p)->member),\ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~ include/linux/compiler.h:240:59: note: expanded from macro '__must_be_array' #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ include/linux/compiler_types.h:264:63: note: expanded from macro '__same_type' #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) ^ include/linux/build_bug.h:16:62: note: expanded from macro 'BUILD_BUG_ON_ZERO' #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) ^ >> drivers/firewire/core-transaction.c:780:20: error: member reference type 'struct fw_request' is not a pointer; did you mean to use '.'? request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:49: note: expanded from macro 'struct_size' sizeof(*(p)->member) + __must_be_array((p)->member),\ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~ include/linux/compiler.h:240:65: note: expanded from macro '__must_be_array' #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ include/linux/compiler_types.h:264:74: note: expanded from macro '__same_type' #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) ^ include/linux/build_bug.h:16:62: note: expanded from macro 'BUILD_BUG_ON_ZERO' #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) ^ >> drivers/firewire/core-transaction.c:780:20: error: indirection requires pointer operand ('struct fw_request' invalid) request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:327:14: note: expanded from macro 'struct_size' sizeof(*(p))) ^~~~ 5 errors generated. vim +780 drivers/firewire/core-transaction.c 743 744 static struct fw_request *allocate_request(struct fw_card *card, 745 struct fw_packet *p) 746 { 747 struct fw_request *request; 748 u32 *data, length; 749 int request_tcode; 750 751 request_tcode = HEADER_GET_TCODE(p->header[0]); 752 switch (request_tcode) { 753 case TCODE_WRITE_QUADLET_REQUEST: 754 data = &p->header[3]; 755 length = 4; 756 break; 757 758 case TCODE_WRITE_BLOCK_REQUEST: 759 case TCODE_LOCK_REQUEST: 760 data = p->payload; 761 length = HEADER_GET_DATA_LENGTH(p->header[3]); 762 break; 763 764 case TCODE_READ_QUADLET_REQUEST: 765 data = NULL; 766 length = 4; 767 break; 768 769 case TCODE_READ_BLOCK_REQUEST: 770 data = NULL; 771 length = HEADER_GET_DATA_LENGTH(p->header[3]); 772 break; 773 774 default: 775 fw_notice(card, "ERROR - corrupt request received - %08x %08x %08x\n", 776 p->header[0], p->header[1], p->header[2]); 777 return NULL; 778 } 779 > 780 request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); 781 if (request == NULL) 782 return NULL; 783 784 request->response.speed = p->speed; 785 request->response.timestamp = 786 compute_split_timeout_timestamp(card, p->timestamp); 787 request->response.generation = p->generation; 788 request->response.ack = 0; 789 request->response.callback = free_response_callback; 790 request->ack = p->ack; 791 request->length = length; 792 if (data) 793 memcpy(request->data, data, length); 794 795 memcpy(request->request_header, p->header, sizeof(p->header)); 796 797 return request; 798 } 799 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers/firewire: use struct_size over open coded arithmetic @ 2022-01-28 12:08 ` kernel test robot 0 siblings, 0 replies; 5+ messages in thread From: kernel test robot @ 2022-01-28 12:08 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 7555 bytes --] 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: hexagon-randconfig-r015-20220128 (https://download.01.org/0day-ci/archive/20220128/202201282044.Ye1mhIOd-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 33b45ee44b1f32ffdbc995e6fec806271b4b3ba4) reproduce (this is a W=1 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/1567c3f747219c35e83d9c1f4ac3c3d36f447d90 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review cgel-zte-gmail-com/drivers-firewire-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=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/firewire/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/firewire/core-transaction.c:780:20: error: member reference type 'struct fw_request' is not a pointer; did you mean to use '.'? request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:18: note: expanded from macro 'struct_size' sizeof(*(p)->member) + __must_be_array((p)->member),\ ~~~^ >> drivers/firewire/core-transaction.c:780:20: error: indirection requires pointer operand ('u32[]' (aka 'unsigned int[]') invalid) request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:14: note: expanded from macro 'struct_size' sizeof(*(p)->member) + __must_be_array((p)->member),\ ^~~~~~~~~~~~ >> drivers/firewire/core-transaction.c:780:20: error: member reference type 'struct fw_request' is not a pointer; did you mean to use '.'? request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:49: note: expanded from macro 'struct_size' sizeof(*(p)->member) + __must_be_array((p)->member),\ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~ include/linux/compiler.h:240:59: note: expanded from macro '__must_be_array' #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ include/linux/compiler_types.h:264:63: note: expanded from macro '__same_type' #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) ^ include/linux/build_bug.h:16:62: note: expanded from macro 'BUILD_BUG_ON_ZERO' #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) ^ >> drivers/firewire/core-transaction.c:780:20: error: member reference type 'struct fw_request' is not a pointer; did you mean to use '.'? request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:326:49: note: expanded from macro 'struct_size' sizeof(*(p)->member) + __must_be_array((p)->member),\ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~ include/linux/compiler.h:240:65: note: expanded from macro '__must_be_array' #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ include/linux/compiler_types.h:264:74: note: expanded from macro '__same_type' #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) ^ include/linux/build_bug.h:16:62: note: expanded from macro 'BUILD_BUG_ON_ZERO' #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) ^ >> drivers/firewire/core-transaction.c:780:20: error: indirection requires pointer operand ('struct fw_request' invalid) request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/overflow.h:327:14: note: expanded from macro 'struct_size' sizeof(*(p))) ^~~~ 5 errors generated. vim +780 drivers/firewire/core-transaction.c 743 744 static struct fw_request *allocate_request(struct fw_card *card, 745 struct fw_packet *p) 746 { 747 struct fw_request *request; 748 u32 *data, length; 749 int request_tcode; 750 751 request_tcode = HEADER_GET_TCODE(p->header[0]); 752 switch (request_tcode) { 753 case TCODE_WRITE_QUADLET_REQUEST: 754 data = &p->header[3]; 755 length = 4; 756 break; 757 758 case TCODE_WRITE_BLOCK_REQUEST: 759 case TCODE_LOCK_REQUEST: 760 data = p->payload; 761 length = HEADER_GET_DATA_LENGTH(p->header[3]); 762 break; 763 764 case TCODE_READ_QUADLET_REQUEST: 765 data = NULL; 766 length = 4; 767 break; 768 769 case TCODE_READ_BLOCK_REQUEST: 770 data = NULL; 771 length = HEADER_GET_DATA_LENGTH(p->header[3]); 772 break; 773 774 default: 775 fw_notice(card, "ERROR - corrupt request received - %08x %08x %08x\n", 776 p->header[0], p->header[1], p->header[2]); 777 return NULL; 778 } 779 > 780 request = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); 781 if (request == NULL) 782 return NULL; 783 784 request->response.speed = p->speed; 785 request->response.timestamp = 786 compute_split_timeout_timestamp(card, p->timestamp); 787 request->response.generation = p->generation; 788 request->response.ack = 0; 789 request->response.callback = free_response_callback; 790 request->ack = p->ack; 791 request->length = length; 792 if (data) 793 memcpy(request->data, data, length); 794 795 memcpy(request->request_header, p->header, sizeof(p->header)); 796 797 return request; 798 } 799 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers/firewire: use struct_size over open coded arithmetic 2022-01-28 8:03 [PATCH] drivers/firewire: use struct_size over open coded arithmetic cgel.zte @ 2022-01-28 14:54 ` kernel test robot 2022-01-28 14:54 ` kernel test robot 1 sibling, 0 replies; 5+ messages in thread From: kernel test robot @ 2022-01-28 14:54 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 8229 bytes --] 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/archive/20220128/202201282234.A43HZoSH-lkp(a)intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0 reproduce (this is a W=1 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/1567c3f747219c35e83d9c1f4ac3c3d36f447d90 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review cgel-zte-gmail-com/drivers-firewire-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=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> 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 '->' (have '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 = 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 '->' (have '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_type' 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 = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); | ^~~~~~~~~~~ include/linux/overflow.h:326:63: error: invalid type argument of '->' (have '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_type' 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 = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); | ^~~~~~~~~~~ include/linux/build_bug.h:16:51: error: bit-field '<anonymous>' width not 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 = 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 = 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() - Calculate 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 the array member. b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 317 * @count: Number of elements 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 number of @member elements. 610b15c50e86eb1 Kees Cook 2018-05-07 321 * 610b15c50e86eb1 Kees Cook 2018-05-07 322 * Return: number of bytes 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)->member) + __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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers/firewire: use struct_size over open coded arithmetic @ 2022-01-28 14:54 ` kernel test robot 0 siblings, 0 replies; 5+ messages in thread From: kernel test robot @ 2022-01-28 14:54 UTC (permalink / raw) To: cgel.zte, stefanr Cc: kbuild-all, linux1394-devel, linux-kernel, Minghao Chi, Zeal Robot 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/archive/20220128/202201282234.A43HZoSH-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0 reproduce (this is a W=1 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/1567c3f747219c35e83d9c1f4ac3c3d36f447d90 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review cgel-zte-gmail-com/drivers-firewire-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=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> 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 '->' (have '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 = 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 '->' (have '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_type' 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 = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); | ^~~~~~~~~~~ include/linux/overflow.h:326:63: error: invalid type argument of '->' (have '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_type' 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 = kmalloc(struct_size(*request, data, length), GFP_ATOMIC); | ^~~~~~~~~~~ include/linux/build_bug.h:16:51: error: bit-field '<anonymous>' width not 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 = 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 = 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() - Calculate 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 the array member. b19d57d0f3cc6f1 Gustavo A. R. Silva 2020-06-08 317 * @count: Number of elements 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 number of @member elements. 610b15c50e86eb1 Kees Cook 2018-05-07 321 * 610b15c50e86eb1 Kees Cook 2018-05-07 322 * Return: number of bytes 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)->member) + __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@lists.01.org ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-28 14:54 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-01-28 8:03 [PATCH] drivers/firewire: use struct_size over open coded arithmetic cgel.zte 2022-01-28 12:08 ` kernel test robot 2022-01-28 12:08 ` kernel test robot 2022-01-28 14:54 ` kernel test robot 2022-01-28 14:54 ` kernel test robot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.