<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Acked-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
<b>Sent:</b> Tuesday, December 29, 2020 1:21 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Wentland, Harry <Harry.Wentland@amd.com><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/display: fix sysfs amdgpu_current_backlight_pwm NULL pointer issue</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">fix NULL pointer issue when read sysfs amdgpu_current_backlight_pwm sysfs node.<br>
<br>
calltrace:<br>
[ 248.273833] BUG: kernel NULL pointer dereference, address: 0000000000000130<br>
[ 248.273930] #PF: supervisor read access in kernel mode<br>
[ 248.273993] #PF: error_code(0x0000) - not-present page<br>
[ 248.274054] PGD 0 P4D 0<br>
[ 248.274092] Oops: 0000 [#1] SMP PTI<br>
[ 248.274138] CPU: 2 PID: 1377 Comm: cat Tainted: G OE 5.9.0-rc5-drm-next-5.9+ #1<br>
[ 248.274233] Hardware name: System manufacturer System Product Name/Z170-A, BIOS 3802 03/15/2018<br>
[ 248.274641] RIP: 0010:dc_link_get_backlight_level+0x5/0x70 [amdgpu]<br>
[ 248.274718] Code: 67 ff ff ff 41 b9 03 00 00 00 e9 45 ff ff ff d1 ea e9 55 ff ff ff 0f 1f 44 00 00 66 2e<br>
0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 <48> 8b 87 30 01 00 00 48 8b 00 48 8b 88 88 03 00 00 48 8d 81 e8 01<br>
[ 248.274919] RSP: 0018:ffffb5ad809b3df0 EFLAGS: 00010203<br>
[ 248.274982] RAX: ffffa0f77d1c0010 RBX: ffffa0f793ae9168 RCX: 0000000000000001<br>
[ 248.275064] RDX: ffffa0f79753db00 RSI: 0000000000000001 RDI: 0000000000000000<br>
[ 248.275145] RBP: ffffb5ad809b3e00 R08: ffffb5ad809b3da0 R09: 0000000000000000<br>
[ 248.275225] R10: ffffb5ad809b3e68 R11: 0000000000000000 R12: ffffa0f793ae9190<br>
[ 248.275306] R13: ffffb5ad809b3ef0 R14: 0000000000000001 R15: ffffa0f793ae9168<br>
[ 248.275388] FS: 00007f5f1ec4d540(0000) GS:ffffa0f79ec80000(0000) knlGS:0000000000000000<br>
[ 248.275480] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033<br>
[ 248.275547] CR2: 0000000000000130 CR3: 000000042a03c005 CR4: 00000000003706e0<br>
[ 248.275628] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000<br>
[ 248.275708] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400<br>
[ 248.275789] Call Trace:<br>
[ 248.276124] ? current_backlight_read+0x24/0x40 [amdgpu]<br>
[ 248.276194] seq_read+0xc3/0x3f0<br>
[ 248.276240] full_proxy_read+0x5c/0x90<br>
[ 248.276290] vfs_read+0xa7/0x190<br>
[ 248.276334] ksys_read+0xa7/0xe0<br>
[ 248.276379] __x64_sys_read+0x1a/0x20<br>
[ 248.276429] do_syscall_64+0x37/0x80<br>
[ 248.276477] entry_SYSCALL_64_after_hwframe+0x44/0xa9<br>
[ 248.276538] RIP: 0033:0x7f5f1e75c191<br>
[ 248.276585] Code: fe ff ff 48 8d 3d b7 9d 0a 00 48 83 ec 08 e8 46 4d 02 00 66 0f 1f 44 00 00 48 8d 05 71 07<br>
2e 00 8b 00 85 c0 75 13 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 57 f3 c3 0f 1f 44 00 00 41 54 55 49 89 d4 53Hw<br>
[ 248.276784] RSP: 002b:00007ffcb1fc3f38 EFLAGS: 00000246 ORIG_RAX: 0000000000000000<br>
[ 248.276872] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007f5f1e75c191<br>
[ 248.276953] RDX: 0000000000020000 RSI: 00007f5f1ec2b000 RDI: 0000000000000003<br>
[ 248.277034] RBP: 0000000000020000 R08: 00000000ffffffff R09: 0000000000000000<br>
[ 248.277115] R10: 0000000000000022 R11: 0000000000000246 R12: 00007f5f1ec2b000<br>
[ 248.277195] R13: 0000000000000003 R14: 00007f5f1ec2b00f R15: 0000000000020000<br>
[ 248.277279] Modules linked in: amdgpu(OE) iommu_v2 gpu_sched ttm(OE) drm_kms_helper cec drm<br>
i2c_algo_bit fb_sys_fops syscopyarea sysfillrect sysimgblt rpcsec_gss_krb5 auth_rpcgss nfsv4 nfs<br>
lockd grace fscache nls_iso8859_1 snd_hda_codec_realtek snd_hda_codec_hdmi snd_hda_codec_generic<br>
ledtrig_audio intel_rapl_msr intel_rapl_common snd_hda_intel snd_intel_dspcfg x86_pkg_temp_thermal<br>
intel_powerclamp snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_seq_midi snd_seq_midi_event mei_hdcp<br>
coretemp snd_rawmidi snd_seq kvm_intel kvm snd_seq_device snd_timer irqbypass joydev snd input_leds soundcore<br>
crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel crypto_simd cryptd glue_helper rapl intel_cstate<br>
mac_hid mei_me serio_raw mei eeepc_wmi wmi_bmof asus_wmi mxm_wmi intel_wmi_thunderbolt acpi_pad sparse_keymap<br>
efi_pstore sch_fq_codel parport_pc ppdev lp parport sunrpc ip_tables x_tables autofs4 hid_logitech_hidpp<br>
hid_logitech_dj hid_generic usbhid hid e1000e psmouse ahci libahci wmi video<br>
[ 248.278211] CR2: 0000000000000130<br>
[ 248.278221] ---[ end trace 1fbe72fe6f91091d ]---<br>
[ 248.357226] RIP: 0010:dc_link_get_backlight_level+0x5/0x70 [amdgpu]<br>
[ 248.357272] Code: 67 ff ff ff 41 b9 03 00 00 00 e9 45 ff ff ff d1 ea e9 55 ff ff ff 0f 1f 44 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 <48> 8b 87 30 01 00 00 48 8b 00 48 8b 88 88 03 00 00 48 8d 81 e8 01<br>
<br>
Signed-off-by: Kevin Wang <kevin1.wang@amd.com><br>
---<br>
drivers/gpu/drm/amd/display/dc/core/dc_link.c | 7 ++++++-<br>
1 file changed, 6 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c<br>
index 9e1071b2181f..f4a2088ab179 100644<br>
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c<br>
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c<br>
@@ -2487,9 +2487,14 @@ enum dc_status dc_link_validate_mode_timing(<br>
static struct abm *get_abm_from_stream_res(const struct dc_link *link)<br>
{<br>
int i;<br>
- struct dc *dc = link->ctx->dc;<br>
+ struct dc *dc = NULL;<br>
struct abm *abm = NULL;<br>
<br>
+ if (!link || !link->ctx)<br>
+ return NULL;<br>
+<br>
+ dc = link->ctx->dc;<br>
+<br>
for (i = 0; i < MAX_PIPES; i++) {<br>
struct pipe_ctx pipe_ctx = dc->current_state->res_ctx.pipe_ctx[i];<br>
struct dc_stream_state *stream = pipe_ctx.stream;<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>