2022-08-15 08:24:51

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] Input: HID-rmi - ignore to rmi_hid_read_block after system resumes.

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/[email protected]/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 <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

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


2022-08-15 11:02:50

by Marge Yang

[permalink] [raw]
Subject: RE: [PATCH] Input: HID-rmi - ignore to rmi_hid_read_block after system resumes.

Hi Dan,
Thanks for your information.
I will fix it on V4 patch.

Thanks
Marge Yang

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Monday, August 15, 2022 4:16 PM
To: [email protected]; margeyang <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Marge Yang <[email protected]>; [email protected]; Vincent Huang <[email protected]>; Marge Yang <[email protected]>
Subject: Re: [PATCH] Input: HID-rmi - ignore to rmi_hid_read_block after system resumes.

CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe.


Hi margeyang,

https://urldefense.proofpoint.com/v2/url?u=https-3A__git-2Dscm.com_docs_git-2Dformat-2Dpatch-23-5Fbase-5Ftree-5Finformation&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=ZPw8UPZC7QjdIlIk0NorBFkiiDexM8yXIDSCUXyvUoI&e= ]

url: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_intel-2Dlab-2Dlkp_linux_commits_margeyang_Input-2DHID-2Drmi-2Dignore-2Dto-2Drmi-5Fhid-5Fread-5Fblock-2Dafter-2Dsystem-2Dresumes_20220801-2D145006&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=qM9oqLWIocmeg-um8b7KrQ7lKvYhttRHtsckOGgVlpg&e=
base: https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_hid_hid.git&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=m7w3BRuQqsSi92tD7Gu4x5PdJHLoevCdc3u2UZbKD4s&e= for-next
config: x86_64-randconfig-m001-20220801 (https://urldefense.proofpoint.com/v2/url?u=https-3A__download.01.org_0day-2Dci_archive_20220814_202208142212.QB3fvm5l-2Dlkp-40intel.com_config&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=7qqbxHlAk9YvxOzNvBC00oePmwYwpvxsoq9bF7lgg3w&e= )
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 <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

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://urldefense.proofpoint.com/v2/url?u=https-3A__01.org_lkp&d=DwIBAg&c=7dfBJ8cXbWjhc0BhImu8wVIoUFmBzj1s88r8EGyM0UY&r=ddk_91asmhyAjxFmXHNIQZ2mVcW0D_eq4tb4409nZ94&m=nlgT-3IvgCsBjboEk2pLpv9NTbEPA_DBxNCtUS1pfsH-sX4rFp4vWip9TKD5bZgD&s=iqPMCIB5YYZdhSl4lFrcKmwdNU-RU2DL046Inhx7mPM&e=