lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202210250926.2aGq89g8-lkp@intel.com>
Date:   Tue, 25 Oct 2022 10:05:48 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Roman Li <Roman.Li@....com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org,
        Alex Deucher <alexander.deucher@....com>,
        Wayne Lin <Wayne.Lin@....com>
Subject: drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:2730
 dm_resume() error: we previously assumed 'aconnector->dc_link' could be null
 (see line 2717)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   337a0a0b63f1c30195733eaacf39e4310a592a68
commit: f4346fb3edf7720db3f7f5e1cab1f667cd024280 drm/amd/display: Fix allocate_mst_payload assert on resume
config: mips-randconfig-m031-20221018
compiler: mips64el-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

New smatch warnings:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:2730 dm_resume() error: we previously assumed 'aconnector->dc_link' could be null (see line 2717)

Old smatch warnings:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:1747 amdgpu_dm_fini() warn: variable dereferenced before check 'adev->dm.dc' (see line 1720)
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4019 amdgpu_dm_backlight_update_status() error: testing array offset 'i' after use.
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4061 amdgpu_dm_backlight_get_brightness() error: testing array offset 'i' after use.
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:6530 create_stream_for_sink() error: we previously assumed 'aconnector->dc_sink' could be null (see line 6429)
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:8918 handle_cursor_update() error: we previously assumed 'afb' could be null (see line 8877)

vim +2730 drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c

4562236b3bc0a2 Harry Wentland      2017-09-12  2606  static int dm_resume(void *handle)
4562236b3bc0a2 Harry Wentland      2017-09-12  2607  {
4562236b3bc0a2 Harry Wentland      2017-09-12  2608  	struct amdgpu_device *adev = handle;
4a580877bdcb83 Luben Tuikov        2020-08-24  2609  	struct drm_device *ddev = adev_to_drm(adev);
4562236b3bc0a2 Harry Wentland      2017-09-12  2610  	struct amdgpu_display_manager *dm = &adev->dm;
c84dec2fe8837f Harry Wentland      2017-09-05  2611  	struct amdgpu_dm_connector *aconnector;
4562236b3bc0a2 Harry Wentland      2017-09-12  2612  	struct drm_connector *connector;
f8d2d39eb40694 Lyude Paul          2019-09-03  2613  	struct drm_connector_list_iter iter;
4562236b3bc0a2 Harry Wentland      2017-09-12  2614  	struct drm_crtc *crtc;
c2cea7063b85fc Leo (Sunpeng  Li    2017-10-12  2615) 	struct drm_crtc_state *new_crtc_state;
fcb4019e090b95 Leo (Sunpeng  Li    2017-11-01  2616) 	struct dm_crtc_state *dm_new_crtc_state;
fcb4019e090b95 Leo (Sunpeng  Li    2017-11-01  2617) 	struct drm_plane *plane;
fcb4019e090b95 Leo (Sunpeng  Li    2017-11-01  2618) 	struct drm_plane_state *new_plane_state;
fcb4019e090b95 Leo (Sunpeng  Li    2017-11-01  2619) 	struct dm_plane_state *dm_new_plane_state;
113b7a01087211 Leo Li              2019-03-19  2620  	struct dm_atomic_state *dm_state = to_dm_atomic_state(dm->atomic_obj.state);
fbbdadf2faf17c Bhawanpreet Lakha   2018-09-26  2621  	enum dc_connection_type new_connection_type = dc_connection_none;
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2622  	struct dc_state *dc_state;
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2623  	int i, r, j;
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2624  
53b3f8f40e6cff Dennis Li           2020-08-19  2625  	if (amdgpu_in_reset(adev)) {
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2626  		dc_state = dm->cached_dc_state;
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2627  
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2628  		/*
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2629  		 * The dc->current_state is backed up into dm->cached_dc_state
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2630  		 * before we commit 0 streams.
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2631  		 *
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2632  		 * DC will clear link encoder assignments on the real state
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2633  		 * but the changes won't propagate over to the copy we made
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2634  		 * before the 0 streams commit.
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2635  		 *
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2636  		 * DC expects that link encoder assignments are *not* valid
32685b32d825ca Nicholas Kazlauskas 2022-02-28  2637  		 * when committing a state, so as a workaround we can copy
32685b32d825ca Nicholas Kazlauskas 2022-02-28  2638  		 * off of the current state.
32685b32d825ca Nicholas Kazlauskas 2022-02-28  2639  		 *
32685b32d825ca Nicholas Kazlauskas 2022-02-28  2640  		 * We lose the previous assignments, but we had already
32685b32d825ca Nicholas Kazlauskas 2022-02-28  2641  		 * commit 0 streams anyway.
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2642  		 */
32685b32d825ca Nicholas Kazlauskas 2022-02-28  2643  		link_enc_cfg_copy(adev->dm.dc->current_state, dc_state);
6d63fcc2a334f7 Nicholas Kazlauskas 2021-11-09  2644  
af6902ec415655 Nicholas Kazlauskas 2021-11-23  2645  		if (dc_enable_dmub_notifications(adev->dm.dc))
524a0ba6fab955 Nicholas Kazlauskas 2021-11-08  2646  			amdgpu_dm_outbox_init(adev);
524a0ba6fab955 Nicholas Kazlauskas 2021-11-08  2647  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2648  		r = dm_dmub_hw_init(adev);
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2649  		if (r)
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2650  			DRM_ERROR("DMUB interface failed to initialize: status=%d\n", r);
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2651  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2652  		dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2653  		dc_resume(dm->dc);
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2654  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2655  		amdgpu_dm_irq_resume_early(adev);
4562236b3bc0a2 Harry Wentland      2017-09-12  2656  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2657  		for (i = 0; i < dc_state->stream_count; i++) {
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2658  			dc_state->streams[i]->mode_changed = true;
6984fa418b8efd Nicholas Kazlauskas 2021-11-09  2659  			for (j = 0; j < dc_state->stream_status[i].plane_count; j++) {
6984fa418b8efd Nicholas Kazlauskas 2021-11-09  2660  				dc_state->stream_status[i].plane_states[j]->update_flags.raw
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2661  					= 0xffffffff;
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2662  			}
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2663  		}
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2664  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2665  		WARN_ON(!dc_commit_state(dm->dc, dc_state));
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2666  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2667  		dm_gpureset_commit_state(dm->cached_dc_state, dm);
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2668  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2669  		dm_gpureset_toggle_interrupts(adev, dm->cached_dc_state, true);
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2670  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2671  		dc_release_state(dm->cached_dc_state);
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2672  		dm->cached_dc_state = NULL;
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2673  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2674  		amdgpu_dm_irq_resume_late(adev);
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2675  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2676  		mutex_unlock(&dm->dc_lock);
4562236b3bc0a2 Harry Wentland      2017-09-12  2677  
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2678  		return 0;
cdaae8371aa9d4 Bhawanpreet Lakha   2020-05-11  2679  	}
113b7a01087211 Leo Li              2019-03-19  2680  	/* Recreate dc_state - DC invalidates it when setting power state to S3. */
113b7a01087211 Leo Li              2019-03-19  2681  	dc_release_state(dm_state->context);
113b7a01087211 Leo Li              2019-03-19  2682  	dm_state->context = dc_create_state(dm->dc);
113b7a01087211 Leo Li              2019-03-19  2683  	/* TODO: Remove dc_state->dccg, use dc->dccg directly. */
113b7a01087211 Leo Li              2019-03-19  2684  	dc_resource_state_construct(dm->dc, dm_state->context);
113b7a01087211 Leo Li              2019-03-19  2685  
af6902ec415655 Nicholas Kazlauskas 2021-11-23  2686  	/* Re-enable outbox interrupts for DPIA. */
af6902ec415655 Nicholas Kazlauskas 2021-11-23  2687  	if (dc_enable_dmub_notifications(adev->dm.dc))
af6902ec415655 Nicholas Kazlauskas 2021-11-23  2688  		amdgpu_dm_outbox_init(adev);
af6902ec415655 Nicholas Kazlauskas 2021-11-23  2689  
8c7aea404d55da Nicholas Kazlauskas 2019-11-25  2690  	/* Before powering on DC we need to re-initialize DMUB. */
79d6b9351f086e Nicholas Kazlauskas 2021-12-15  2691  	dm_dmub_hw_resume(adev);
8c7aea404d55da Nicholas Kazlauskas 2019-11-25  2692  
a80aa93de1a0e6 Mikita Lipski       2018-02-03  2693  	/* power on hardware */
a80aa93de1a0e6 Mikita Lipski       2018-02-03  2694  	dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
a80aa93de1a0e6 Mikita Lipski       2018-02-03  2695  
4562236b3bc0a2 Harry Wentland      2017-09-12  2696  	/* program HPD filter */
4562236b3bc0a2 Harry Wentland      2017-09-12  2697  	dc_resume(dm->dc);
4562236b3bc0a2 Harry Wentland      2017-09-12  2698  
4562236b3bc0a2 Harry Wentland      2017-09-12  2699  	/*
4562236b3bc0a2 Harry Wentland      2017-09-12  2700  	 * early enable HPD Rx IRQ, should be done before set mode as short
4562236b3bc0a2 Harry Wentland      2017-09-12  2701  	 * pulse interrupts are used for MST
4562236b3bc0a2 Harry Wentland      2017-09-12  2702  	 */
4562236b3bc0a2 Harry Wentland      2017-09-12  2703  	amdgpu_dm_irq_resume_early(adev);
4562236b3bc0a2 Harry Wentland      2017-09-12  2704  
684cd480fd4e6d Lyude Paul          2019-09-25  2705  	/* On resume we need to rewrite the MSTM control bits to enable MST*/
684cd480fd4e6d Lyude Paul          2019-09-25  2706  	s3_handle_mst(ddev, false);
684cd480fd4e6d Lyude Paul          2019-09-25  2707  
4562236b3bc0a2 Harry Wentland      2017-09-12  2708  	/* Do detection*/
f8d2d39eb40694 Lyude Paul          2019-09-03  2709  	drm_connector_list_iter_begin(ddev, &iter);
f8d2d39eb40694 Lyude Paul          2019-09-03  2710  	drm_for_each_connector_iter(connector, &iter) {
c84dec2fe8837f Harry Wentland      2017-09-05  2711  		aconnector = to_amdgpu_dm_connector(connector);
4562236b3bc0a2 Harry Wentland      2017-09-12  2712  
4562236b3bc0a2 Harry Wentland      2017-09-12  2713  		/*
4562236b3bc0a2 Harry Wentland      2017-09-12  2714  		 * this is the case when traversing through already created
4562236b3bc0a2 Harry Wentland      2017-09-12  2715  		 * MST connectors, should be skipped
4562236b3bc0a2 Harry Wentland      2017-09-12  2716  		 */
f4346fb3edf772 Roman Li            2022-03-17 @2717  		if (aconnector->dc_link &&
                                                                    ^^^^^^^^^^^^^^^^^^^
Probably this check can be deleted...

f4346fb3edf772 Roman Li            2022-03-17  2718  		    aconnector->dc_link->type == dc_connection_mst_branch)
4562236b3bc0a2 Harry Wentland      2017-09-12  2719  			continue;
4562236b3bc0a2 Harry Wentland      2017-09-12  2720  
03ea364c8e156b Arindam Nath        2017-04-26  2721  		mutex_lock(&aconnector->hpd_lock);
fbbdadf2faf17c Bhawanpreet Lakha   2018-09-26  2722  		if (!dc_link_detect_sink(aconnector->dc_link, &new_connection_type))
fbbdadf2faf17c Bhawanpreet Lakha   2018-09-26  2723  			DRM_ERROR("KMS: Failed to detect connector\n");
fbbdadf2faf17c Bhawanpreet Lakha   2018-09-26  2724  
fbbdadf2faf17c Bhawanpreet Lakha   2018-09-26  2725  		if (aconnector->base.force && new_connection_type == dc_connection_none)
fbbdadf2faf17c Bhawanpreet Lakha   2018-09-26  2726  			emulated_link_detect(aconnector->dc_link);
fbbdadf2faf17c Bhawanpreet Lakha   2018-09-26  2727  		else
8f38b66c826188 Hersen Wu           2017-09-11  2728  			dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD);
3eb4eba42263cc Roman Li            2017-10-20  2729  
3eb4eba42263cc Roman Li            2017-10-20 @2730  		if (aconnector->fake_enable && aconnector->dc_link->local_sink)
                                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The other code does not bother to check.

3eb4eba42263cc Roman Li            2017-10-20  2731  			aconnector->fake_enable = false;
3eb4eba42263cc Roman Li            2017-10-20  2732  
dcd5fb82ffb484 Mathias Fröhlich    2019-02-10  2733  		if (aconnector->dc_sink)

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ