[PATCH 6/9] drm/i915/display: iterare through channels if no feasible frequencies

Dan Carpenter dan.carpenter at linaro.org
Thu Oct 10 06:49:45 UTC 2024


Hi Vinod,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vinod-Govindapillai/drm-i915-display-get-rid-of-encoder-param-in-intel_audio_compute_config/20241008-163033
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
patch link:    https://lore.kernel.org/r/20241008082327.342020-7-vinod.govindapillai%40intel.com
patch subject: [PATCH 6/9] drm/i915/display: iterare through channels if no feasible frequencies
config: x86_64-randconfig-161-20241009 (https://download.01.org/0day-ci/archive/20241010/202410100801.8jZBRn3y-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)

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 <lkp at intel.com>
| Reported-by: Dan Carpenter <dan.carpenter at linaro.org>
| Closes: https://lore.kernel.org/r/202410100801.8jZBRn3y-lkp@intel.com/

smatch warnings:
drivers/gpu/drm/i915/display/intel_audio.c:789 intel_audio_compute_sad() error: uninitialized symbol 'sad_freq'.

vim +/sad_freq +789 drivers/gpu/drm/i915/display/intel_audio.c

0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  764  static void intel_audio_compute_sad(struct drm_i915_private *i915,
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  765  				    int line_freq_khz, int hblank_slots_lanes,
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  766  				    int avail_overhead, int req_overhead,
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  767  				    struct cea_sad *sad)
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  768  {
e2675520fb74591 Vinod Govindapillai 2024-10-08  769  	u8 channels;
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  770  	u8 sad_freq;
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  771  
e2675520fb74591 Vinod Govindapillai 2024-10-08  772  	/*
e2675520fb74591 Vinod Govindapillai 2024-10-08  773  	 * If we don't find any supported audio frequencies for a channel,
e2675520fb74591 Vinod Govindapillai 2024-10-08  774  	 * reduce the channel and try
e2675520fb74591 Vinod Govindapillai 2024-10-08  775  	 */
e2675520fb74591 Vinod Govindapillai 2024-10-08  776  	for (channels = sad->channels + 1; channels >= 1; channels--) {

This driver is old.  In the era when this driver was written, we used to just
say that if you hit this bug then you deserved it.  We wouldn't bother to fix
something like this.  These days we have syzbot doing millions of stupid things
per second to try break the kernel.

You'd have to use the /proc file to set sad->channels to 255.  Then channels
would be zero and we wouldn't enter the loop.  Potentially, we could add some
sanity checking to snd_hdmi_write_eld_info()?  Another idea would be to make
channels an int instead of a u8.

My other concern is with the "+ 1".  In drm_edid_cta_sad_set() we set channels
as:

	cta_sad->channels = sad[0] & 0x07;

fine.  But in hdmi_update_short_audio_desc() we set channels as:

	a->channels = GRAB_BITS(buf, 0, 0, 3);
	a->channels++;

The first line is exact same in both functions but in hdmi_update_short_audio_desc()
we add "+ 1" and then we add another "+ 1" in this intel_audio_compute_sad()
function.  I suspect the a->channels++; line should be deleted.

0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  777  		sad_freq = intel_audio_get_pruned_audfreq(i915, line_freq_khz,
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  778  							  hblank_slots_lanes,
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  779  							  avail_overhead,
e2675520fb74591 Vinod Govindapillai 2024-10-08  780  							  req_overhead,
e2675520fb74591 Vinod Govindapillai 2024-10-08  781  							  channels,
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  782  							  sad->freq);
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  783  
e2675520fb74591 Vinod Govindapillai 2024-10-08  784  		/* Supported frequencies exist! No need to proceed further */
e2675520fb74591 Vinod Govindapillai 2024-10-08  785  		if (sad_freq)
e2675520fb74591 Vinod Govindapillai 2024-10-08  786  			break;
e2675520fb74591 Vinod Govindapillai 2024-10-08  787  	}
e2675520fb74591 Vinod Govindapillai 2024-10-08  788  
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08 @789  	sad->freq = sad_freq;
e2675520fb74591 Vinod Govindapillai 2024-10-08  790  	sad->channels = channels ? channels - 1 : 0;
0f1adcd58da8c47 Vinod Govindapillai 2024-10-08  791  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki



More information about the Intel-gfx mailing list