Re: [PATCH] drm/amd/display: fix null-pointer dereference on edid reading

2024-02-16 Thread Melissa Wen
On 02/15, Alex Deucher wrote:
> On Thu, Feb 15, 2024 at 12:35 PM Melissa Wen  wrote:
> >
> > Use i2c adapter when there isn't aux_mode in dc_link to fix a
> > null-pointer derefence that happens when running
> > igt@kms_force_connector_basic in a system with DCN2.1 and HDMI connector
> > detected as below:
> >
> > [  +0.178146] BUG: kernel NULL pointer dereference, address: 
> > 04c0
> > [  +0.10] #PF: supervisor read access in kernel mode
> > [  +0.05] #PF: error_code(0x) - not-present page
> > [  +0.04] PGD 0 P4D 0
> > [  +0.06] Oops:  [#1] PREEMPT SMP NOPTI
> > [  +0.06] CPU: 15 PID: 2368 Comm: kms_force_conne Not tainted 
> > 6.5.0-asdn+ #152
> > [  +0.05] Hardware name: HP HP ENVY x360 Convertible 13-ay1xxx/8929, 
> > BIOS F.01 07/14/2021
> > [  +0.04] RIP: 0010:i2c_transfer+0xd/0x100
> > [  +0.11] Code: ea fc ff ff 66 0f 1f 84 00 00 00 00 00 90 90 90 90 90 
> > 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 0f 1f 44 00 00 41 54 55 53 
> > <48> 8b 47 10 48 89 fb 48 83 38 00 0f 84 b3 00 00 00 83 3d 2f 80 16
> > [  +0.04] RSP: 0018:9c4f89c0fad0 EFLAGS: 00010246
> > [  +0.05] RAX:  RBX: 0005 RCX: 
> > 0080
> > [  +0.03] RDX: 0002 RSI: 9c4f89c0fb20 RDI: 
> > 04b0
> > [  +0.03] RBP: 9c4f89c0fb80 R08: 0080 R09: 
> > 8d8e0b15b980
> > [  +0.03] R10: 000380e0 R11:  R12: 
> > 0080
> > [  +0.02] R13: 0002 R14: 9c4f89c0fb0e R15: 
> > 9c4f89c0fb0f
> > [  +0.04] FS:  7f9ad2176c40() GS:8d90fe9c() 
> > knlGS:
> > [  +0.03] CS:  0010 DS:  ES:  CR0: 80050033
> > [  +0.04] CR2: 04c0 CR3: 000121bc4000 CR4: 
> > 00750ee0
> > [  +0.03] PKRU: 5554
> > [  +0.03] Call Trace:
> > [  +0.06]  
> > [  +0.06]  ? __die+0x23/0x70
> > [  +0.11]  ? page_fault_oops+0x17d/0x4c0
> > [  +0.08]  ? preempt_count_add+0x6e/0xa0
> > [  +0.08]  ? srso_alias_return_thunk+0x5/0x7f
> > [  +0.11]  ? exc_page_fault+0x7f/0x180
> > [  +0.09]  ? asm_exc_page_fault+0x26/0x30
> > [  +0.13]  ? i2c_transfer+0xd/0x100
> > [  +0.10]  drm_do_probe_ddc_edid+0xc2/0x140 [drm]
> > [  +0.67]  ? srso_alias_return_thunk+0x5/0x7f
> > [  +0.06]  ? _drm_do_get_edid+0x97/0x3c0 [drm]
> > [  +0.43]  ? __pfx_drm_do_probe_ddc_edid+0x10/0x10 [drm]
> > [  +0.42]  edid_block_read+0x3b/0xd0 [drm]
> > [  +0.43]  _drm_do_get_edid+0xb6/0x3c0 [drm]
> > [  +0.41]  ? __pfx_drm_do_probe_ddc_edid+0x10/0x10 [drm]
> > [  +0.43]  drm_edid_read_custom+0x37/0xd0 [drm]
> > [  +0.44]  amdgpu_dm_connector_mode_valid+0x129/0x1d0 [amdgpu]
> > [  +0.000153]  drm_connector_mode_valid+0x3b/0x60 [drm_kms_helper]
> > [  +0.00]  __drm_helper_update_and_validate+0xfe/0x3c0 [drm_kms_helper]
> > [  +0.00]  ? amdgpu_dm_connector_get_modes+0xb6/0x520 [amdgpu]
> > [  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
> > [  +0.00]  drm_helper_probe_single_connector_modes+0x2ab/0x540 
> > [drm_kms_helper]
> > [  +0.00]  status_store+0xb2/0x1f0 [drm]
> > [  +0.00]  kernfs_fop_write_iter+0x136/0x1d0
> > [  +0.00]  vfs_write+0x24d/0x440
> > [  +0.00]  ksys_write+0x6f/0xf0
> > [  +0.00]  do_syscall_64+0x60/0xc0
> > [  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
> > [  +0.00]  ? syscall_exit_to_user_mode+0x2b/0x40
> > [  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
> > [  +0.00]  ? do_syscall_64+0x6c/0xc0
> > [  +0.00]  ? do_syscall_64+0x6c/0xc0
> > [  +0.00]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> > [  +0.00] RIP: 0033:0x7f9ad46b4b00
> > [  +0.00] Code: 40 00 48 8b 15 19 b3 0d 00 f7 d8 64 89 02 48 c7 c0 ff 
> > ff ff ff eb b7 0f 1f 00 80 3d e1 3a 0e 00 00 74 17 b8 01 00 00 00 0f 05 
> > <48> 3d 00 f0 ff ff 77 58 c3 0f 1f 80 00 00 00 00 48 83 ec 28 48 89
> > [  +0.00] RSP: 002b:7ffcbd3bd6d8 EFLAGS: 0202 ORIG_RAX: 
> > 0001
> > [  +0.00] RAX: ffda RBX:  RCX: 
> > 7f9ad46b4b00
> > [  +0.00] RDX: 0002 RSI: 7f9ad48a7417 RDI: 
> > 0009
> > [  +0.00] RBP: 0002 R08: 0064 R09: 
> > 
> > [  +0.00] R10:  R11: 0202 R12: 
> > 7f9ad48a7417
> > [  +0.00] R13: 0009 R14: 7ffcbd3bd760 R15: 
> > 0001
> > [  +0.00]  
> > [  +0.00] Modules linked in: ctr ccm rfcomm snd_seq_dummy snd_hrtimer 
> > snd_seq snd_seq_device cmac algif_hash algif_skcipher af_alg bnep btusb 
> > btrtl btbcm btintel btmtk bluetooth uvcvideo videobuf2_vmalloc sha3_generic 
> > videobuf2_memops uvc jitterentropy_rng videobuf2_v4l2 videodev drbg 
> > videobuf2_common ansi_cprng mc ecdh_generic ecc qrtr binfmt_misc 
> > hid_sensor_accel_3d hid_sensor_magn_3d hid_sensor_gyro_3d 
> > hid_sensor_trigger 

Re: [PATCH] drm/amd/display: fix null-pointer dereference on edid reading

2024-02-15 Thread Alex Deucher
On Thu, Feb 15, 2024 at 12:35 PM Melissa Wen  wrote:
>
> Use i2c adapter when there isn't aux_mode in dc_link to fix a
> null-pointer derefence that happens when running
> igt@kms_force_connector_basic in a system with DCN2.1 and HDMI connector
> detected as below:
>
> [  +0.178146] BUG: kernel NULL pointer dereference, address: 04c0
> [  +0.10] #PF: supervisor read access in kernel mode
> [  +0.05] #PF: error_code(0x) - not-present page
> [  +0.04] PGD 0 P4D 0
> [  +0.06] Oops:  [#1] PREEMPT SMP NOPTI
> [  +0.06] CPU: 15 PID: 2368 Comm: kms_force_conne Not tainted 6.5.0-asdn+ 
> #152
> [  +0.05] Hardware name: HP HP ENVY x360 Convertible 13-ay1xxx/8929, BIOS 
> F.01 07/14/2021
> [  +0.04] RIP: 0010:i2c_transfer+0xd/0x100
> [  +0.11] Code: ea fc ff ff 66 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 
> 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 0f 1f 44 00 00 41 54 55 53 <48> 8b 
> 47 10 48 89 fb 48 83 38 00 0f 84 b3 00 00 00 83 3d 2f 80 16
> [  +0.04] RSP: 0018:9c4f89c0fad0 EFLAGS: 00010246
> [  +0.05] RAX:  RBX: 0005 RCX: 
> 0080
> [  +0.03] RDX: 0002 RSI: 9c4f89c0fb20 RDI: 
> 04b0
> [  +0.03] RBP: 9c4f89c0fb80 R08: 0080 R09: 
> 8d8e0b15b980
> [  +0.03] R10: 000380e0 R11:  R12: 
> 0080
> [  +0.02] R13: 0002 R14: 9c4f89c0fb0e R15: 
> 9c4f89c0fb0f
> [  +0.04] FS:  7f9ad2176c40() GS:8d90fe9c() 
> knlGS:
> [  +0.03] CS:  0010 DS:  ES:  CR0: 80050033
> [  +0.04] CR2: 04c0 CR3: 000121bc4000 CR4: 
> 00750ee0
> [  +0.03] PKRU: 5554
> [  +0.03] Call Trace:
> [  +0.06]  
> [  +0.06]  ? __die+0x23/0x70
> [  +0.11]  ? page_fault_oops+0x17d/0x4c0
> [  +0.08]  ? preempt_count_add+0x6e/0xa0
> [  +0.08]  ? srso_alias_return_thunk+0x5/0x7f
> [  +0.11]  ? exc_page_fault+0x7f/0x180
> [  +0.09]  ? asm_exc_page_fault+0x26/0x30
> [  +0.13]  ? i2c_transfer+0xd/0x100
> [  +0.10]  drm_do_probe_ddc_edid+0xc2/0x140 [drm]
> [  +0.67]  ? srso_alias_return_thunk+0x5/0x7f
> [  +0.06]  ? _drm_do_get_edid+0x97/0x3c0 [drm]
> [  +0.43]  ? __pfx_drm_do_probe_ddc_edid+0x10/0x10 [drm]
> [  +0.42]  edid_block_read+0x3b/0xd0 [drm]
> [  +0.43]  _drm_do_get_edid+0xb6/0x3c0 [drm]
> [  +0.41]  ? __pfx_drm_do_probe_ddc_edid+0x10/0x10 [drm]
> [  +0.43]  drm_edid_read_custom+0x37/0xd0 [drm]
> [  +0.44]  amdgpu_dm_connector_mode_valid+0x129/0x1d0 [amdgpu]
> [  +0.000153]  drm_connector_mode_valid+0x3b/0x60 [drm_kms_helper]
> [  +0.00]  __drm_helper_update_and_validate+0xfe/0x3c0 [drm_kms_helper]
> [  +0.00]  ? amdgpu_dm_connector_get_modes+0xb6/0x520 [amdgpu]
> [  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
> [  +0.00]  drm_helper_probe_single_connector_modes+0x2ab/0x540 
> [drm_kms_helper]
> [  +0.00]  status_store+0xb2/0x1f0 [drm]
> [  +0.00]  kernfs_fop_write_iter+0x136/0x1d0
> [  +0.00]  vfs_write+0x24d/0x440
> [  +0.00]  ksys_write+0x6f/0xf0
> [  +0.00]  do_syscall_64+0x60/0xc0
> [  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
> [  +0.00]  ? syscall_exit_to_user_mode+0x2b/0x40
> [  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
> [  +0.00]  ? do_syscall_64+0x6c/0xc0
> [  +0.00]  ? do_syscall_64+0x6c/0xc0
> [  +0.00]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> [  +0.00] RIP: 0033:0x7f9ad46b4b00
> [  +0.00] Code: 40 00 48 8b 15 19 b3 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff 
> ff ff eb b7 0f 1f 00 80 3d e1 3a 0e 00 00 74 17 b8 01 00 00 00 0f 05 <48> 3d 
> 00 f0 ff ff 77 58 c3 0f 1f 80 00 00 00 00 48 83 ec 28 48 89
> [  +0.00] RSP: 002b:7ffcbd3bd6d8 EFLAGS: 0202 ORIG_RAX: 
> 0001
> [  +0.00] RAX: ffda RBX:  RCX: 
> 7f9ad46b4b00
> [  +0.00] RDX: 0002 RSI: 7f9ad48a7417 RDI: 
> 0009
> [  +0.00] RBP: 0002 R08: 0064 R09: 
> 
> [  +0.00] R10:  R11: 0202 R12: 
> 7f9ad48a7417
> [  +0.00] R13: 0009 R14: 7ffcbd3bd760 R15: 
> 0001
> [  +0.00]  
> [  +0.00] Modules linked in: ctr ccm rfcomm snd_seq_dummy snd_hrtimer 
> snd_seq snd_seq_device cmac algif_hash algif_skcipher af_alg bnep btusb btrtl 
> btbcm btintel btmtk bluetooth uvcvideo videobuf2_vmalloc sha3_generic 
> videobuf2_memops uvc jitterentropy_rng videobuf2_v4l2 videodev drbg 
> videobuf2_common ansi_cprng mc ecdh_generic ecc qrtr binfmt_misc 
> hid_sensor_accel_3d hid_sensor_magn_3d hid_sensor_gyro_3d hid_sensor_trigger 
> industrialio_triggered_buffer kfifo_buf industrialio snd_ctl_led joydev 
> hid_sensor_iio_common rtw89_8852ae rtw89_8852a rtw89_pci 
> snd_hda_codec_realtek rtw89_core snd_hda_codec_generic intel_rapl_msr 
> ledtrig_audio 

[PATCH] drm/amd/display: fix null-pointer dereference on edid reading

2024-02-15 Thread Melissa Wen
Use i2c adapter when there isn't aux_mode in dc_link to fix a
null-pointer derefence that happens when running
igt@kms_force_connector_basic in a system with DCN2.1 and HDMI connector
detected as below:

[  +0.178146] BUG: kernel NULL pointer dereference, address: 04c0
[  +0.10] #PF: supervisor read access in kernel mode
[  +0.05] #PF: error_code(0x) - not-present page
[  +0.04] PGD 0 P4D 0
[  +0.06] Oops:  [#1] PREEMPT SMP NOPTI
[  +0.06] CPU: 15 PID: 2368 Comm: kms_force_conne Not tainted 6.5.0-asdn+ 
#152
[  +0.05] Hardware name: HP HP ENVY x360 Convertible 13-ay1xxx/8929, BIOS 
F.01 07/14/2021
[  +0.04] RIP: 0010:i2c_transfer+0xd/0x100
[  +0.11] Code: ea fc ff ff 66 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 
90 90 90 90 90 90 90 90 90 f3 0f 1e fa 0f 1f 44 00 00 41 54 55 53 <48> 8b 47 10 
48 89 fb 48 83 38 00 0f 84 b3 00 00 00 83 3d 2f 80 16
[  +0.04] RSP: 0018:9c4f89c0fad0 EFLAGS: 00010246
[  +0.05] RAX:  RBX: 0005 RCX: 0080
[  +0.03] RDX: 0002 RSI: 9c4f89c0fb20 RDI: 04b0
[  +0.03] RBP: 9c4f89c0fb80 R08: 0080 R09: 8d8e0b15b980
[  +0.03] R10: 000380e0 R11:  R12: 0080
[  +0.02] R13: 0002 R14: 9c4f89c0fb0e R15: 9c4f89c0fb0f
[  +0.04] FS:  7f9ad2176c40() GS:8d90fe9c() 
knlGS:
[  +0.03] CS:  0010 DS:  ES:  CR0: 80050033
[  +0.04] CR2: 04c0 CR3: 000121bc4000 CR4: 00750ee0
[  +0.03] PKRU: 5554
[  +0.03] Call Trace:
[  +0.06]  
[  +0.06]  ? __die+0x23/0x70
[  +0.11]  ? page_fault_oops+0x17d/0x4c0
[  +0.08]  ? preempt_count_add+0x6e/0xa0
[  +0.08]  ? srso_alias_return_thunk+0x5/0x7f
[  +0.11]  ? exc_page_fault+0x7f/0x180
[  +0.09]  ? asm_exc_page_fault+0x26/0x30
[  +0.13]  ? i2c_transfer+0xd/0x100
[  +0.10]  drm_do_probe_ddc_edid+0xc2/0x140 [drm]
[  +0.67]  ? srso_alias_return_thunk+0x5/0x7f
[  +0.06]  ? _drm_do_get_edid+0x97/0x3c0 [drm]
[  +0.43]  ? __pfx_drm_do_probe_ddc_edid+0x10/0x10 [drm]
[  +0.42]  edid_block_read+0x3b/0xd0 [drm]
[  +0.43]  _drm_do_get_edid+0xb6/0x3c0 [drm]
[  +0.41]  ? __pfx_drm_do_probe_ddc_edid+0x10/0x10 [drm]
[  +0.43]  drm_edid_read_custom+0x37/0xd0 [drm]
[  +0.44]  amdgpu_dm_connector_mode_valid+0x129/0x1d0 [amdgpu]
[  +0.000153]  drm_connector_mode_valid+0x3b/0x60 [drm_kms_helper]
[  +0.00]  __drm_helper_update_and_validate+0xfe/0x3c0 [drm_kms_helper]
[  +0.00]  ? amdgpu_dm_connector_get_modes+0xb6/0x520 [amdgpu]
[  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
[  +0.00]  drm_helper_probe_single_connector_modes+0x2ab/0x540 
[drm_kms_helper]
[  +0.00]  status_store+0xb2/0x1f0 [drm]
[  +0.00]  kernfs_fop_write_iter+0x136/0x1d0
[  +0.00]  vfs_write+0x24d/0x440
[  +0.00]  ksys_write+0x6f/0xf0
[  +0.00]  do_syscall_64+0x60/0xc0
[  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
[  +0.00]  ? syscall_exit_to_user_mode+0x2b/0x40
[  +0.00]  ? srso_alias_return_thunk+0x5/0x7f
[  +0.00]  ? do_syscall_64+0x6c/0xc0
[  +0.00]  ? do_syscall_64+0x6c/0xc0
[  +0.00]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
[  +0.00] RIP: 0033:0x7f9ad46b4b00
[  +0.00] Code: 40 00 48 8b 15 19 b3 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff 
ff eb b7 0f 1f 00 80 3d e1 3a 0e 00 00 74 17 b8 01 00 00 00 0f 05 <48> 3d 00 f0 
ff ff 77 58 c3 0f 1f 80 00 00 00 00 48 83 ec 28 48 89
[  +0.00] RSP: 002b:7ffcbd3bd6d8 EFLAGS: 0202 ORIG_RAX: 
0001
[  +0.00] RAX: ffda RBX:  RCX: 7f9ad46b4b00
[  +0.00] RDX: 0002 RSI: 7f9ad48a7417 RDI: 0009
[  +0.00] RBP: 0002 R08: 0064 R09: 
[  +0.00] R10:  R11: 0202 R12: 7f9ad48a7417
[  +0.00] R13: 0009 R14: 7ffcbd3bd760 R15: 0001
[  +0.00]  
[  +0.00] Modules linked in: ctr ccm rfcomm snd_seq_dummy snd_hrtimer 
snd_seq snd_seq_device cmac algif_hash algif_skcipher af_alg bnep btusb btrtl 
btbcm btintel btmtk bluetooth uvcvideo videobuf2_vmalloc sha3_generic 
videobuf2_memops uvc jitterentropy_rng videobuf2_v4l2 videodev drbg 
videobuf2_common ansi_cprng mc ecdh_generic ecc qrtr binfmt_misc 
hid_sensor_accel_3d hid_sensor_magn_3d hid_sensor_gyro_3d hid_sensor_trigger 
industrialio_triggered_buffer kfifo_buf industrialio snd_ctl_led joydev 
hid_sensor_iio_common rtw89_8852ae rtw89_8852a rtw89_pci snd_hda_codec_realtek 
rtw89_core snd_hda_codec_generic intel_rapl_msr ledtrig_audio intel_rapl_common 
snd_hda_codec_hdmi mac80211 snd_hda_intel snd_intel_dspcfg kvm_amd 
snd_hda_codec snd_soc_dmic snd_acp3x_rn snd_acp3x_pdm_dma libarc4 snd_hwdep 
snd_soc_core kvm snd_hda_core cfg80211 snd_pci_acp6x snd_pcm nls_ascii 
snd_timer hp_wmi snd_pci_acp5x 

Re: [PATCH] drm/amd/display: Fix NULL pointer dereference at hibernate

2023-11-30 Thread Harry Wentland

On 2023-11-28 19:35, Mario Limonciello wrote:

During hibernate sequence the source context might not have a clk_mgr.
So don't use it to look for DML2 support.

Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2980
Fixes: a2815ada8616 ("drm/amd/display: Introduce DML2")
Signed-off-by: Mario Limonciello 


Reviewed-by: Harry Wentland 

Harry


---
  drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index f3a9fdd2340d..e1c02527d04a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -4554,7 +4554,7 @@ void dc_resource_state_copy_construct(
struct dml2_context *dml2 = NULL;
  
  	// Need to preserve allocated dml2 context

-   if (src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
+   if (src_ctx->clk_mgr && src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
dml2 = dst_ctx->bw_ctx.dml2;
  #endif
  
@@ -4562,7 +4562,7 @@ void dc_resource_state_copy_construct(
  
  #ifdef CONFIG_DRM_AMD_DC_FP

// Preserve allocated dml2 context
-   if (src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
+   if (src_ctx->clk_mgr && src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
dst_ctx->bw_ctx.dml2 = dml2;
  #endif
  


[PATCH] drm/amd/display: Fix NULL pointer dereference at hibernate

2023-11-29 Thread Mario Limonciello
During hibernate sequence the source context might not have a clk_mgr.
So don't use it to look for DML2 support.

Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2980
Fixes: a2815ada8616 ("drm/amd/display: Introduce DML2")
Signed-off-by: Mario Limonciello 
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index f3a9fdd2340d..e1c02527d04a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -4554,7 +4554,7 @@ void dc_resource_state_copy_construct(
struct dml2_context *dml2 = NULL;
 
// Need to preserve allocated dml2 context
-   if (src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
+   if (src_ctx->clk_mgr && src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
dml2 = dst_ctx->bw_ctx.dml2;
 #endif
 
@@ -4562,7 +4562,7 @@ void dc_resource_state_copy_construct(
 
 #ifdef CONFIG_DRM_AMD_DC_FP
// Preserve allocated dml2 context
-   if (src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
+   if (src_ctx->clk_mgr && src_ctx->clk_mgr->ctx->dc->debug.using_dml2)
dst_ctx->bw_ctx.dml2 = dml2;
 #endif
 
-- 
2.34.1



[PATCH] drm/amd/display: fix null pointer dereference

2017-10-27 Thread S, Shirish

From: Shirish S 

While setting cursor position in case of mpo, input_pixel_processor is not 
available for underlay, hence add check of the same to avoid null pointer 
access issue.

Signed-off-by: Shirish S 
Reviewed-by: Harry Wentland 
Reviewed-by: Tony Cheng 
---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index 5cf69af..572b885 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -288,7 +288,7 @@ bool dc_stream_set_cursor_position(
pos_cpy.enable = false;
 
 
-   if (ipp->funcs->ipp_cursor_set_position != NULL)
+   if (ipp !=NULL && ipp->funcs->ipp_cursor_set_position != NULL)
ipp->funcs->ipp_cursor_set_position(ipp, _cpy, 
);
 
if (mi != NULL && mi->funcs->set_cursor_position != NULL)
--
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


RE: [PATCH] drm/amd/display: fix NULL pointer dereference.

2017-04-05 Thread Quan, Evan
The issue seems already fixed by the following commit
{{{
commit 52184bbf4773512d7c83fe21a0b4b4ec4be27caf
Author: Jordan Lazare <jordan.laz...@amd.com>
Date:   Wed Apr 5 15:05:51 2017 -0400

drm/amd/display: fix nullptr on vega initialization

Change-Id: Ic5062d9b9e7ad3406c8ed0acfe0e2f222ce17634
Signed-off-by: Jordan Lazare <jordan.laz...@amd.com>
Reviewed-by: Tony Cheng <tony.ch...@amd.com>
Reviewed-by: Roman Li <roman...@amd.com>
}}}

Regards,
Evan
>-Original Message-
>From: amd-gfx [mailto:amd-gfx-boun...@lists.freedesktop.org] On Behalf Of
>Rex Zhu
>Sent: Wednesday, April 05, 2017 3:55 PM
>To: amd-gfx@lists.freedesktop.org
>Cc: Zhu, Rex <rex....@amd.com>
>Subject: [PATCH] drm/amd/display: fix NULL pointer dereference.
>
>on vega10, driver can run into a NULL-pointer dereference.
>
>Change-Id: I8e2de5343f804d6e736f620ff6d3d6e6488fb970
>Signed-off-by: Rex Zhu <rex@amd.com>
>---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>index 62be159..8f5951f 100644
>--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>@@ -1095,7 +1095,8 @@ int amdgpu_dm_initialize_drm_device(struct
>amdgpu_device *adev)
>   DRM_ERROR("KMS: Failed to allocate surface\n");
>   goto fail_free_planes;
>   }
>-  mode_info->planes[i]->plane_type = mode_info-
>>plane_type[i];
>+  if (mode_info->plane_type != NULL)
>+  mode_info->planes[i]->plane_type = mode_info-
>>plane_type[i];
>   if (amdgpu_dm_plane_init(dm, mode_info->planes[i], 1)) {
>   DRM_ERROR("KMS: Failed to initialize plane\n");
>   goto fail_free_planes;
>--
>1.9.1
>
>___
>amd-gfx mailing list
>amd-gfx@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


RE: [PATCH] drm/amd/display: fix NULL pointer dereference.

2017-04-05 Thread Zhang, Jerry
> -Original Message-
> From: amd-gfx [mailto:amd-gfx-boun...@lists.freedesktop.org] On Behalf Of
> Rex Zhu
> Sent: Wednesday, April 05, 2017 15:55
> To: amd-gfx@lists.freedesktop.org
> Cc: Zhu, Rex
> Subject: [PATCH] drm/amd/display: fix NULL pointer dereference.
> 
> on vega10, driver can run into a NULL-pointer dereference.
> 
> Change-Id: I8e2de5343f804d6e736f620ff6d3d6e6488fb970
> Signed-off-by: Rex Zhu <rex@amd.com>
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 62be159..8f5951f 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -1095,7 +1095,8 @@ int amdgpu_dm_initialize_drm_device(struct
> amdgpu_device *adev)
>   DRM_ERROR("KMS: Failed to allocate surface\n");
>   goto fail_free_planes;
>   }
> - mode_info->planes[i]->plane_type = mode_info->plane_type[i];
> + if (mode_info->plane_type != NULL)

We can simplify it like:
if (mode_info->plane_type)

With that fix,   
Reviewed-by: Junwei Zhang <jerry.zh...@amd.com>

> + mode_info->planes[i]->plane_type = mode_info-
> >plane_type[i];
>   if (amdgpu_dm_plane_init(dm, mode_info->planes[i], 1)) {
>   DRM_ERROR("KMS: Failed to initialize plane\n");
>   goto fail_free_planes;
> --
> 1.9.1
> 
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH] drm/amd/display: fix NULL pointer dereference.

2017-04-05 Thread Rex Zhu
on vega10, driver can run into a NULL-pointer dereference.

Change-Id: I8e2de5343f804d6e736f620ff6d3d6e6488fb970
Signed-off-by: Rex Zhu 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 62be159..8f5951f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1095,7 +1095,8 @@ int amdgpu_dm_initialize_drm_device(struct amdgpu_device 
*adev)
DRM_ERROR("KMS: Failed to allocate surface\n");
goto fail_free_planes;
}
-   mode_info->planes[i]->plane_type = mode_info->plane_type[i];
+   if (mode_info->plane_type != NULL)
+   mode_info->planes[i]->plane_type = 
mode_info->plane_type[i];
if (amdgpu_dm_plane_init(dm, mode_info->planes[i], 1)) {
DRM_ERROR("KMS: Failed to initialize plane\n");
goto fail_free_planes;
-- 
1.9.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx