drivers/platform/x86/amd/hsmp.c:367 hsmp_metric_tbl_read() error: we previously assumed 'sock' could be null (see line 366)
kernel test robot
build botBCC: [email protected]
CC: [email protected]
CC: Andy Shevchenko <[email protected]>
CC: Hans de Goede <[email protected]>
TO: Suma Hegde <[email protected]>
CC: "Ilpo Järvinen" <[email protected]>
CC: Naveen Krishna Chatradhi <[email protected]>
CC: Hans de Goede <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git review-ilpo head: d04e52b47ab62cf36fddaa0feb1c5508e420e48d commit: 7a5a66d63b8fb8ac60ef8e2ad989310c270a4fac [11/17] platform/x86/amd/hsmp: Move dev from platdev to hsmp_socket
:::::: branch date: 4 days ago
:::::: commit date: 4 days ago
config: x86_64-randconfig-161-20240128 (https://download.01.org/0day-ci/archive/20240129/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:drivers/platform/x86/amd/hsmp.c:367 hsmp_metric_tbl_read() error: we previously assumed 'sock' could be null (see line 366)
vim +/sock +367 drivers/platform/x86/amd/hsmp.c
91f410aa679a03 drivers/platform/x86/amd_hsmp.c Suma Hegde 2022-02-22 351
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 352 static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 353 struct bin_attribute *bin_attr, char *buf,
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 354 loff_t off, size_t count)
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 355 {
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 356 struct hsmp_socket *sock = bin_attr->private;
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 357 struct hsmp_message msg = { 0 };
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 358 int ret;
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 359
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 360 /* Do not support lseek(), reads entire metric table */
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 361 if (count < bin_attr->size) {
7a5a66d63b8fb8 drivers/platform/x86/amd/hsmp.c Suma Hegde 2024-01-06 362 dev_err(sock->dev, "Wrong buffer size\n");
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 363 return -EINVAL;
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 364 }
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 365
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 @366 if (!sock) {
7a5a66d63b8fb8 drivers/platform/x86/amd/hsmp.c Suma Hegde 2024-01-06 @367 dev_err(sock->dev, "Failed to read attribute private data\n");
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 368 return -EINVAL;
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 369 }
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 370
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 371 msg.msg_id = HSMP_GET_METRIC_TABLE;
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 372 msg.sock_ind = sock->sock_ind;
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 373
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 374 ret = hsmp_send_message(&msg);
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 375 if (ret)
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 376 return ret;
02a258ac3ebf8a drivers/platform/x86/amd/hsmp.c Armin Wolf 2023-10-19 377 memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size);
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 378
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 379 return bin_attr->size;
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 380 }
5150542b8ec5fb drivers/platform/x86/amd/hsmp.c Suma Hegde 2023-10-10 381 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki