Re: [PATCH] Input: HID-rmi - ignore to rmi_hid_read_block after system resumes.
From: Dan Carpenter
Date: Mon Aug 15 2022 - 04:17:17 EST
Hi margeyang,
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/margeyang/Input-HID-rmi-ignore-to-rmi_hid_read_block-after-system-resumes/20220801-145006
base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
config: x86_64-randconfig-m001-20220801 (https://download.01.org/0day-ci/archive/20220814/202208142212.QB3fvm5l-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
New smatch warnings:
drivers/hid/hid-rmi.c:263 rmi_hid_read_block() error: uninitialized symbol 'ret'.
vim +/ret +263 drivers/hid/hid-rmi.c
0b2c7a897378f1 Andrew Duggan 2017-01-05 188 static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,
0b2c7a897378f1 Andrew Duggan 2017-01-05 189 void *buf, size_t len)
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 190 {
0b2c7a897378f1 Andrew Duggan 2017-01-05 191 struct rmi_data *data = container_of(xport, struct rmi_data, xport);
0b2c7a897378f1 Andrew Duggan 2017-01-05 192 struct hid_device *hdev = data->hdev;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 193 int ret;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 194 int bytes_read;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 195 int bytes_needed;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 196 int retries;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 197 int read_input_count;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 198
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 199 mutex_lock(&data->page_mutex);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 200
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 201 if (RMI_PAGE(addr) != data->page) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 202 ret = rmi_set_page(hdev, RMI_PAGE(addr));
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 203 if (ret < 0)
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 204 goto exit;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 205 }
30a3df7ece6145 Marge Yang 2022-08-01 206 if (ignoreonce == 1) {
30a3df7ece6145 Marge Yang 2022-08-01 207 dev_err(&hdev->dev,
30a3df7ece6145 Marge Yang 2022-08-01 208 "ignoreonce (%d)\n",
30a3df7ece6145 Marge Yang 2022-08-01 209 ignoreonce);
30a3df7ece6145 Marge Yang 2022-08-01 210 ignoreonce = 0;
"ret" not initialized here.
30a3df7ece6145 Marge Yang 2022-08-01 211 goto exit;
30a3df7ece6145 Marge Yang 2022-08-01 212 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 213 for (retries = 5; retries > 0; retries--) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 214 data->writeReport[0] = RMI_READ_ADDR_REPORT_ID;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 215 data->writeReport[1] = 0; /* old 1 byte read count */
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 216 data->writeReport[2] = addr & 0xFF;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 217 data->writeReport[3] = (addr >> 8) & 0xFF;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 218 data->writeReport[4] = len & 0xFF;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 219 data->writeReport[5] = (len >> 8) & 0xFF;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 220
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 221 set_bit(RMI_READ_REQUEST_PENDING, &data->flags);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 222
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 223 ret = rmi_write_report(hdev, data->writeReport,
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 224 data->output_report_size);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 225 if (ret != data->output_report_size) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 226 dev_err(&hdev->dev,
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 227 "failed to write request output report (%d)\n",
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 228 ret);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 229 goto exit;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 230 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 231
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 232 bytes_read = 0;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 233 bytes_needed = len;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 234 while (bytes_read < len) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 235 if (!wait_event_timeout(data->wait,
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 236 test_bit(RMI_READ_DATA_PENDING, &data->flags),
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 237 msecs_to_jiffies(1000))) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 238 hid_warn(hdev, "%s: timeout elapsed\n",
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 239 __func__);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 240 ret = -EAGAIN;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 241 break;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 242 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 243
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 244 read_input_count = data->readReport[1];
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 245 memcpy(buf + bytes_read, &data->readReport[2],
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 246 read_input_count < bytes_needed ?
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 247 read_input_count : bytes_needed);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 248
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 249 bytes_read += read_input_count;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 250 bytes_needed -= read_input_count;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 251 clear_bit(RMI_READ_DATA_PENDING, &data->flags);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 252 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 253
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 254 if (ret >= 0) {
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 255 ret = 0;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 256 break;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 257 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 258 }
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 259
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 260 exit:
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 261 clear_bit(RMI_READ_REQUEST_PENDING, &data->flags);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 262 mutex_unlock(&data->page_mutex);
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 @263 return ret;
9fb6bf02e3ad04 Benjamin Tissoires 2014-04-07 264 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp