All of lore.kernel.org
 help / color / mirror / Atom feed
* [mchinth:sep_socwatch_linux_5.8 17/38] drivers/platform/x86/socwatch/sw_driver.c:697 sw_set_driver_infos_i() warn: variable dereferenced before check 'local_msg' (see line 694)
@ 2020-08-07 10:49 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-08-07 10:49 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 11747 bytes --]

tree:   https://github.com/mchinth/linux sep_socwatch_linux_5.8
head:   9b0862a82e9ad6b0eec974f450499ed714da96cd
commit: ec64fc1d1d301f55264c7da61b5fd063981a6dc2 [17/38] platform/x86: SOCPERF3 support for sep & socwatch
config: x86_64-randconfig-m001-20200807 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

New smatch warnings:
drivers/platform/x86/socwatch/sw_driver.c:697 sw_set_driver_infos_i() warn: variable dereferenced before check 'local_msg' (see line 694)
drivers/platform/x86/socwatch/sw_driver.c:1089 sw_set_continuous_i() warn: inconsistent indenting
drivers/platform/x86/socwatch/sw_tracepoint_handlers.c:341 sw_reg_unreg_node_i() warn: argument 2 to %lx specifier is cast from pointer

Old smatch warnings:
drivers/platform/x86/socwatch/sw_driver.c:256 sw_print_collector_node_i() warn: statement has no effect 3
drivers/platform/x86/socwatch/sw_driver.c:997 sw_get_available_name_id_mappings_i() warn: maybe return -EFAULT instead of the bytes remaining?
drivers/platform/x86/socwatch/sw_driver.c:1047 sw_get_topology_changes_i() warn: maybe return -EFAULT instead of the bytes remaining?
drivers/platform/x86/socwatch/sw_driver.c:1168 sw_unlocked_handle_ioctl_i() warn: inconsistent indenting

vim +/local_msg +697 drivers/platform/x86/socwatch/sw_driver.c

78edc9c56f9f3b Jon Moeller    2018-11-13  663  
78edc9c56f9f3b Jon Moeller    2018-11-13  664  /**
78edc9c56f9f3b Jon Moeller    2018-11-13  665   * sw_set_driver_infos_i - Process the collection config data passed down
78edc9c56f9f3b Jon Moeller    2018-11-13  666   *                         from the client.
78edc9c56f9f3b Jon Moeller    2018-11-13  667   * @remote_msg: The user space address of our ioctl data.
78edc9c56f9f3b Jon Moeller    2018-11-13  668   * @local_len:  The number of bytes of remote_msg we should copy.
78edc9c56f9f3b Jon Moeller    2018-11-13  669   *
78edc9c56f9f3b Jon Moeller    2018-11-13  670   * This function copies the ioctl data from user space to kernel
78edc9c56f9f3b Jon Moeller    2018-11-13  671   * space.  That data is an array of sw_driver_interface_info structs,
78edc9c56f9f3b Jon Moeller    2018-11-13  672   * which hold information about tracepoints, notifiers, and collector
78edc9c56f9f3b Jon Moeller    2018-11-13  673   * configuration info for this collection run..  For each driver_info
78edc9c56f9f3b Jon Moeller    2018-11-13  674   * struct, it calls the appropriate "add info" (registration/
78edc9c56f9f3b Jon Moeller    2018-11-13  675   * configuration) function for each of the "when types" (begin, poll,
78edc9c56f9f3b Jon Moeller    2018-11-13  676   * notifier, tracepoint, end) which should trigger a collection
78edc9c56f9f3b Jon Moeller    2018-11-13  677   * operation for that collector.
78edc9c56f9f3b Jon Moeller    2018-11-13  678   *
78edc9c56f9f3b Jon Moeller    2018-11-13  679   * When this function is done, the data structures corresponding to
78edc9c56f9f3b Jon Moeller    2018-11-13  680   * collection should be configured and initialized.
78edc9c56f9f3b Jon Moeller    2018-11-13  681   *
78edc9c56f9f3b Jon Moeller    2018-11-13  682   *
78edc9c56f9f3b Jon Moeller    2018-11-13  683   * Returns: PW_SUCCESS on success, or a non-zero on an error.
78edc9c56f9f3b Jon Moeller    2018-11-13  684   */
78edc9c56f9f3b Jon Moeller    2018-11-13  685  static long
78edc9c56f9f3b Jon Moeller    2018-11-13  686  sw_set_driver_infos_i(struct sw_driver_interface_msg __user *remote_msg,
78edc9c56f9f3b Jon Moeller    2018-11-13  687  		      int local_len)
78edc9c56f9f3b Jon Moeller    2018-11-13  688  {
78edc9c56f9f3b Jon Moeller    2018-11-13  689  	struct sw_driver_interface_info *local_info = NULL;
78edc9c56f9f3b Jon Moeller    2018-11-13  690  	struct sw_driver_interface_msg *local_msg = vmalloc(local_len);
78edc9c56f9f3b Jon Moeller    2018-11-13  691  	pw_u8_t read_triggers = 0x0;
78edc9c56f9f3b Jon Moeller    2018-11-13  692  	pw_u16_t num_infos = 0;
78edc9c56f9f3b Jon Moeller    2018-11-13  693  	sw_when_type_t i = SW_WHEN_TYPE_BEGIN;
78edc9c56f9f3b Jon Moeller    2018-11-13 @694  	char *__data = (char *)local_msg->infos;
78edc9c56f9f3b Jon Moeller    2018-11-13  695  	size_t dst_idx = 0;
78edc9c56f9f3b Jon Moeller    2018-11-13  696  
78edc9c56f9f3b Jon Moeller    2018-11-13 @697  	if (!local_msg) {
78edc9c56f9f3b Jon Moeller    2018-11-13  698  		pw_pr_error("ERROR allocating space for local message!\n");
78edc9c56f9f3b Jon Moeller    2018-11-13  699  		return -EFAULT;
78edc9c56f9f3b Jon Moeller    2018-11-13  700  	}
78edc9c56f9f3b Jon Moeller    2018-11-13  701  	if (copy_from_user(local_msg, (struct sw_driver_interface_msg __user *)
78edc9c56f9f3b Jon Moeller    2018-11-13  702  			   remote_msg, local_len)) {
78edc9c56f9f3b Jon Moeller    2018-11-13  703  		pw_pr_error("ERROR copying message from user space!\n");
78edc9c56f9f3b Jon Moeller    2018-11-13  704  		vfree(local_msg);
78edc9c56f9f3b Jon Moeller    2018-11-13  705  		return -EFAULT;
78edc9c56f9f3b Jon Moeller    2018-11-13  706  	}
78edc9c56f9f3b Jon Moeller    2018-11-13  707  	/*
78edc9c56f9f3b Jon Moeller    2018-11-13  708  	 * We aren't allowed to config the driver multiple times between
78edc9c56f9f3b Jon Moeller    2018-11-13  709  	 * collections. Clear out any previous config values.
78edc9c56f9f3b Jon Moeller    2018-11-13  710  	 */
78edc9c56f9f3b Jon Moeller    2018-11-13  711  	sw_destroy_collector_lists_i();
78edc9c56f9f3b Jon Moeller    2018-11-13  712  
78edc9c56f9f3b Jon Moeller    2018-11-13  713  	/*
78edc9c56f9f3b Jon Moeller    2018-11-13  714  	 * Did the user specify a min polling interval?
78edc9c56f9f3b Jon Moeller    2018-11-13  715  	 */
78edc9c56f9f3b Jon Moeller    2018-11-13  716  	sw_min_polling_interval_msecs = local_msg->min_polling_interval_msecs;
78edc9c56f9f3b Jon Moeller    2018-11-13  717  	pw_pr_debug("min_polling_interval_msecs = %u\n",
78edc9c56f9f3b Jon Moeller    2018-11-13  718  		    sw_min_polling_interval_msecs);
78edc9c56f9f3b Jon Moeller    2018-11-13  719  
78edc9c56f9f3b Jon Moeller    2018-11-13  720  	num_infos = local_msg->num_infos;
78edc9c56f9f3b Jon Moeller    2018-11-13  721  	pw_pr_debug("LOCAL NUM INFOS = %u\n", num_infos);
78edc9c56f9f3b Jon Moeller    2018-11-13  722  	for (; num_infos > 0; --num_infos) {
78edc9c56f9f3b Jon Moeller    2018-11-13  723  		local_info =
78edc9c56f9f3b Jon Moeller    2018-11-13  724  			(struct sw_driver_interface_info *)&__data[dst_idx];
78edc9c56f9f3b Jon Moeller    2018-11-13  725  		dst_idx += (SW_DRIVER_INTERFACE_INFO_HEADER_SIZE() +
78edc9c56f9f3b Jon Moeller    2018-11-13  726  			    local_info->num_io_descriptors *
78edc9c56f9f3b Jon Moeller    2018-11-13  727  				    sizeof(struct sw_driver_io_descriptor));
78edc9c56f9f3b Jon Moeller    2018-11-13  728  		read_triggers = local_info->trigger_bits;
78edc9c56f9f3b Jon Moeller    2018-11-13  729  		pw_pr_debug(
78edc9c56f9f3b Jon Moeller    2018-11-13  730  			"read_triggers = %u, # msrs = %u, new dst_idx = %u\n",
78edc9c56f9f3b Jon Moeller    2018-11-13  731  			(unsigned int)read_triggers,
78edc9c56f9f3b Jon Moeller    2018-11-13  732  			(unsigned int)local_info->num_io_descriptors,
78edc9c56f9f3b Jon Moeller    2018-11-13  733  			(unsigned int)dst_idx);
78edc9c56f9f3b Jon Moeller    2018-11-13  734  		for (i = SW_WHEN_TYPE_BEGIN; i <= SW_WHEN_TYPE_END;
78edc9c56f9f3b Jon Moeller    2018-11-13  735  		     ++i, read_triggers >>= 1) {
a9b1dd14035394 Jon Moeller    2018-12-15  736  			if (read_triggers & 0x1) { /* Bit 'i' is set */
78edc9c56f9f3b Jon Moeller    2018-11-13  737  				pw_pr_debug("BIT %d is SET!\n", i);
78edc9c56f9f3b Jon Moeller    2018-11-13  738  				if (i == SW_WHEN_TYPE_TRACEPOINT) {
78edc9c56f9f3b Jon Moeller    2018-11-13  739  					struct tn_data tn_data = {
78edc9c56f9f3b Jon Moeller    2018-11-13  740  						local_info,
78edc9c56f9f3b Jon Moeller    2018-11-13  741  						local_info->tracepoint_id_mask
78edc9c56f9f3b Jon Moeller    2018-11-13  742  					};
78edc9c56f9f3b Jon Moeller    2018-11-13  743  					pw_pr_debug(
78edc9c56f9f3b Jon Moeller    2018-11-13  744  						"TRACEPOINT, MASK = 0x%llx\n",
78edc9c56f9f3b Jon Moeller    2018-11-13  745  						local_info->tracepoint_id_mask);
78edc9c56f9f3b Jon Moeller    2018-11-13  746  					sw_for_each_tracepoint_node(
78edc9c56f9f3b Jon Moeller    2018-11-13  747  					   &sw_add_trace_notifier_driver_info_i,
78edc9c56f9f3b Jon Moeller    2018-11-13  748  					   &tn_data,
78edc9c56f9f3b Jon Moeller    2018-11-13  749  					   false /*return-on-error*/);
78edc9c56f9f3b Jon Moeller    2018-11-13  750  				} else if (i == SW_WHEN_TYPE_NOTIFIER) {
78edc9c56f9f3b Jon Moeller    2018-11-13  751  					struct tn_data tn_data = {
78edc9c56f9f3b Jon Moeller    2018-11-13  752  						local_info,
78edc9c56f9f3b Jon Moeller    2018-11-13  753  						local_info->notifier_id_mask
78edc9c56f9f3b Jon Moeller    2018-11-13  754  					};
78edc9c56f9f3b Jon Moeller    2018-11-13  755  					pw_pr_debug(
78edc9c56f9f3b Jon Moeller    2018-11-13  756  						"NOTIFIER, MASK = 0x%llx\n",
78edc9c56f9f3b Jon Moeller    2018-11-13  757  						local_info->notifier_id_mask);
78edc9c56f9f3b Jon Moeller    2018-11-13  758  					sw_for_each_notifier_node(
78edc9c56f9f3b Jon Moeller    2018-11-13  759  					   &sw_add_trace_notifier_driver_info_i,
78edc9c56f9f3b Jon Moeller    2018-11-13  760  					   &tn_data,
78edc9c56f9f3b Jon Moeller    2018-11-13  761  					   false /*return-on-error*/);
78edc9c56f9f3b Jon Moeller    2018-11-13  762  				} else {
78edc9c56f9f3b Jon Moeller    2018-11-13  763  					if (sw_add_driver_info(
78edc9c56f9f3b Jon Moeller    2018-11-13  764  						    &sw_collector_lists[i],
5017a92fe4a6e9 Faycal Benmlih 2019-04-23  765  						    local_info))
78edc9c56f9f3b Jon Moeller    2018-11-13  766  						pw_pr_error(
78edc9c56f9f3b Jon Moeller    2018-11-13  767  							"WARNING: could NOT add driver info to list for 'when type' %d!\n",
78edc9c56f9f3b Jon Moeller    2018-11-13  768  							i);
78edc9c56f9f3b Jon Moeller    2018-11-13  769  				}
78edc9c56f9f3b Jon Moeller    2018-11-13  770  			}
78edc9c56f9f3b Jon Moeller    2018-11-13  771  		}
78edc9c56f9f3b Jon Moeller    2018-11-13  772  	}
78edc9c56f9f3b Jon Moeller    2018-11-13  773  	if (sw_for_each_hw_op(&sw_post_config_i, NULL,
5017a92fe4a6e9 Faycal Benmlih 2019-04-23  774  			      false /*return-on-error*/))
78edc9c56f9f3b Jon Moeller    2018-11-13  775  		pw_pr_error("POST-CONFIG error!\n");
5017a92fe4a6e9 Faycal Benmlih 2019-04-23  776  
78edc9c56f9f3b Jon Moeller    2018-11-13  777  	vfree(local_msg);
78edc9c56f9f3b Jon Moeller    2018-11-13  778  	memset(&s_internal_state, 0, sizeof(s_internal_state));
78edc9c56f9f3b Jon Moeller    2018-11-13  779  	/*
78edc9c56f9f3b Jon Moeller    2018-11-13  780  	 * DEBUG: iterate over collection lists.
78edc9c56f9f3b Jon Moeller    2018-11-13  781  	 */
78edc9c56f9f3b Jon Moeller    2018-11-13  782  	sw_iterate_driver_info_lists_i();
78edc9c56f9f3b Jon Moeller    2018-11-13  783  	return PW_SUCCESS;
78edc9c56f9f3b Jon Moeller    2018-11-13  784  }
78edc9c56f9f3b Jon Moeller    2018-11-13  785  

:::::: The code at line 697 was first introduced by commit
:::::: 78edc9c56f9f3b7ab3510ac5f32209d0ef6aef90 platform/x86: add sep and socwatch drivers without socperf.

:::::: TO: Jon Moeller <jon.moeller@intel.com>
:::::: CC: Faycal Benmlih <faycal.benmlih@intel.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37487 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-07 10:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-07 10:49 [mchinth:sep_socwatch_linux_5.8 17/38] drivers/platform/x86/socwatch/sw_driver.c:697 sw_set_driver_infos_i() warn: variable dereferenced before check 'local_msg' (see line 694) 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.