[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202201201212.O8wvhLQc-lkp@intel.com>
Date: Thu, 20 Jan 2022 12:29:07 +0800
From: kernel test robot <lkp@...el.com>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
"Geoffrey D. Bennett" <g@...vu>, Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>
Cc: llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
alsa-devel@...a-project.org, linux-kernel@...r.kernel.org,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] ALSA: usb-audio: scarlett2: Use struct_size()
helper in scarlett2_usb()
Hi "Gustavo,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.16 next-20220118]
[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/Gustavo-A-R-Silva/ALSA-usb-audio-scarlett2-Use-struct_size-helper-in-scarlett2_usb/20220120-080908
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: i386-randconfig-a003-20220117 (https://download.01.org/0day-ci/archive/20220120/202201201212.O8wvhLQc-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project f7b7138a62648f4019c55e4671682af1f851f295)
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/1696152f12c0a7d23ccd5e228f9d08f7bd2da83a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gustavo-A-R-Silva/ALSA-usb-audio-scarlett2-Use-struct_size-helper-in-scarlett2_usb/20220120-080908
git checkout 1696152f12c0a7d23ccd5e228f9d08f7bd2da83a
# 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=i386 SHELL=/bin/bash sound/usb/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
>> sound/usb/mixer_scarlett_gen2.c:1115:14: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
cmd, err, resp_buf_size);
^~~~~~~~~~~~~
sound/usb/usbaudio.h:67:36: note: expanded from macro 'usb_audio_err'
dev_err(&(chip)->dev->dev, fmt, ##args)
~~~ ^~~~
include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
_p_func(dev, fmt, ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
1 warning generated.
vim +1115 sound/usb/mixer_scarlett_gen2.c
1f7fa6e5afbf20 Geoffrey D. Bennett 2021-06-22 1056
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1057 /* Send a proprietary format request to the Scarlett interface */
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1058 static int scarlett2_usb(
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1059 struct usb_mixer_interface *mixer, u32 cmd,
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1060 void *req_data, u16 req_size, void *resp_data, u16 resp_size)
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1061 {
e46f2195c86b00 Geoffrey D. Bennett 2021-06-21 1062 struct scarlett2_data *private = mixer->private_data;
1f7fa6e5afbf20 Geoffrey D. Bennett 2021-06-22 1063 struct usb_device *dev = mixer->chip->dev;
b677b6c6d82248 Geoffrey D. Bennett 2021-06-21 1064 struct scarlett2_usb_packet *req, *resp = NULL;
1696152f12c0a7 Gustavo A. R. Silva 2022-01-19 1065 size_t req_buf_size = struct_size(req, data, req_size);
1696152f12c0a7 Gustavo A. R. Silva 2022-01-19 1066 size_t resp_buf_size = struct_size(resp, data, resp_size);
b677b6c6d82248 Geoffrey D. Bennett 2021-06-21 1067 int err;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1068
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1069 req = kmalloc(req_buf_size, GFP_KERNEL);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1070 if (!req) {
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1071 err = -ENOMEM;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1072 goto error;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1073 }
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1074
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1075 resp = kmalloc(resp_buf_size, GFP_KERNEL);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1076 if (!resp) {
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1077 err = -ENOMEM;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1078 goto error;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1079 }
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1080
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1081 mutex_lock(&private->usb_mutex);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1082
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1083 /* build request message and send it */
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1084
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1085 scarlett2_fill_request_header(private, req, cmd, req_size);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1086
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1087 if (req_size)
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1088 memcpy(req->data, req_data, req_size);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1089
1f7fa6e5afbf20 Geoffrey D. Bennett 2021-06-22 1090 err = scarlett2_usb_tx(dev, private->bInterfaceNumber,
1f7fa6e5afbf20 Geoffrey D. Bennett 2021-06-22 1091 req, req_buf_size);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1092
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1093 if (err != req_buf_size) {
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1094 usb_audio_err(
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1095 mixer->chip,
4be47798d76e6e Geoffrey D. Bennett 2021-06-23 1096 "Scarlett Gen 2/3 USB request result cmd %x was %d\n",
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1097 cmd, err);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1098 err = -EINVAL;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1099 goto unlock;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1100 }
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1101
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1102 /* send a second message to get the response */
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1103
1f7fa6e5afbf20 Geoffrey D. Bennett 2021-06-22 1104 err = scarlett2_usb_rx(dev, private->bInterfaceNumber,
1f7fa6e5afbf20 Geoffrey D. Bennett 2021-06-22 1105 SCARLETT2_USB_CMD_RESP,
1f7fa6e5afbf20 Geoffrey D. Bennett 2021-06-22 1106 resp, resp_buf_size);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1107
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1108 /* validate the response */
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1109
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1110 if (err != resp_buf_size) {
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1111 usb_audio_err(
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1112 mixer->chip,
4be47798d76e6e Geoffrey D. Bennett 2021-06-23 1113 "Scarlett Gen 2/3 USB response result cmd %x was %d "
1696152f12c0a7 Gustavo A. R. Silva 2022-01-19 1114 "expected %lu\n",
acf91b8122c7f6 Geoffrey D. Bennett 2021-06-22 @1115 cmd, err, resp_buf_size);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1116 err = -EINVAL;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1117 goto unlock;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1118 }
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1119
acf91b8122c7f6 Geoffrey D. Bennett 2021-06-22 1120 /* cmd/seq/size should match except when initialising
acf91b8122c7f6 Geoffrey D. Bennett 2021-06-22 1121 * seq sent = 1, response = 0
acf91b8122c7f6 Geoffrey D. Bennett 2021-06-22 1122 */
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1123 if (resp->cmd != req->cmd ||
acf91b8122c7f6 Geoffrey D. Bennett 2021-06-22 1124 (resp->seq != req->seq &&
acf91b8122c7f6 Geoffrey D. Bennett 2021-06-22 1125 (le16_to_cpu(req->seq) != 1 || resp->seq != 0)) ||
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1126 resp_size != le16_to_cpu(resp->size) ||
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1127 resp->error ||
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1128 resp->pad) {
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1129 usb_audio_err(
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1130 mixer->chip,
4be47798d76e6e Geoffrey D. Bennett 2021-06-23 1131 "Scarlett Gen 2/3 USB invalid response; "
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1132 "cmd tx/rx %d/%d seq %d/%d size %d/%d "
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1133 "error %d pad %d\n",
d8f489355cff55 Takashi Iwai 2020-02-01 1134 le32_to_cpu(req->cmd), le32_to_cpu(resp->cmd),
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1135 le16_to_cpu(req->seq), le16_to_cpu(resp->seq),
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1136 resp_size, le16_to_cpu(resp->size),
d8f489355cff55 Takashi Iwai 2020-02-01 1137 le32_to_cpu(resp->error),
d8f489355cff55 Takashi Iwai 2020-02-01 1138 le32_to_cpu(resp->pad));
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1139 err = -EINVAL;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1140 goto unlock;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1141 }
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1142
acf91b8122c7f6 Geoffrey D. Bennett 2021-06-22 1143 if (resp_data && resp_size > 0)
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1144 memcpy(resp_data, resp->data, resp_size);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1145
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1146 unlock:
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1147 mutex_unlock(&private->usb_mutex);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1148 error:
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1149 kfree(req);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1150 kfree(resp);
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1151 return err;
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1152 }
9e4d5c1be21f0c Geoffrey D. Bennett 2019-07-29 1153
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Powered by blists - more mailing lists