Tina Zhang
a2fcd5c84f
drm/modes: Prevent division by zero htotal
This patch prevents division by zero htotal.
In a follow-up mail Tina writes:
> > How did you manage to get here with htotal == 0? This needs backtraces (or if
> > this is just about static checkers, a mention of that).
> > -Daniel
>
> In GVT-g, we are trying to enable a virtual display w/o setting timings for a pipe
> (a.k.a htotal=0), then we met the following kernel panic:
>
> [ 32.832048] divide error: 0000 [#1] SMP PTI
> [ 32.833614] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.18.0-rc4-sriov+ #33
> [ 32.834438] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.10.1-0-g8891697-dirty-20180511_165818-tinazhang-linux-1 04/01/2014
> [ 32.835901] RIP: 0010:drm_mode_hsync+0x1e/0x40
> [ 32.836004] Code: 31 c0 c3 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 8b 87 d8 00 00 00 85 c0 75 22 8b 4f 68 85 c9 78 1b 69 47 58 e8 03 00 00 99 <f7> f9 b9 d3 4d 62 10 05 f4 01 00 00 f7 e1 89 d0 c1 e8 06 f3 c3 66
> [ 32.836004] RSP: 0000:ffffc900000ebb90 EFLAGS: 00010206
> [ 32.836004] RAX: 0000000000000000 RBX: ffff88001c67c8a0 RCX: 0000000000000000
> [ 32.836004] RDX: 0000000000000000 RSI: ffff88001c67c000 RDI: ffff88001c67c8a0
> [ 32.836004] RBP: ffff88001c7d03a0 R08: ffff88001c67c8a0 R09: ffff88001c7d0330
> [ 32.836004] R10: ffffffff822c3a98 R11: 0000000000000001 R12: ffff88001c67c000
> [ 32.836004] R13: ffff88001c7d0370 R14: ffffffff8207eb78 R15: ffff88001c67c800
> [ 32.836004] FS: 0000000000000000(0000) GS:ffff88001da00000(0000) knlGS:0000000000000000
> [ 32.836004] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 32.836004] CR2: 0000000000000000 CR3: 000000000220a000 CR4: 00000000000006f0
> [ 32.836004] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [ 32.836004] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> [ 32.836004] Call Trace:
> [ 32.836004] intel_mode_from_pipe_config+0x72/0x90
> [ 32.836004] intel_modeset_setup_hw_state+0x569/0xf90
> [ 32.836004] intel_modeset_init+0x905/0x1db0
> [ 32.836004] i915_driver_load+0xb8c/0x1120
> [ 32.836004] i915_pci_probe+0x4d/0xb0
> [ 32.836004] local_pci_probe+0x44/0xa0
> [ 32.836004] ? pci_assign_irq+0x27/0x130
> [ 32.836004] pci_device_probe+0x102/0x1c0
> [ 32.836004] driver_probe_device+0x2b8/0x480
> [ 32.836004] __driver_attach+0x109/0x110
> [ 32.836004] ? driver_probe_device+0x480/0x480
> [ 32.836004] bus_for_each_dev+0x67/0xc0
> [ 32.836004] ? klist_add_tail+0x3b/0x70
> [ 32.836004] bus_add_driver+0x1e8/0x260
> [ 32.836004] driver_register+0x5b/0xe0
> [ 32.836004] ? mipi_dsi_bus_init+0x11/0x11
> [ 32.836004] do_one_initcall+0x4d/0x1eb
> [ 32.836004] kernel_init_freeable+0x197/0x237
> [ 32.836004] ? rest_init+0xd0/0xd0
> [ 32.836004] kernel_init+0xa/0x110
> [ 32.836004] ret_from_fork+0x35/0x40
> [ 32.836004] Modules linked in:
> [ 32.859183] ---[ end trace 525608b0ed0e8665 ]---
> [ 32.859722] RIP: 0010:drm_mode_hsync+0x1e/0x40
> [ 32.860287] Code: 31 c0 c3 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 8b 87 d8 00 00 00 85 c0 75 22 8b 4f 68 85 c9 78 1b 69 47 58 e8 03 00 00 99 <f7> f9 b9 d3 4d 62 10 05 f4 01 00 00 f7 e1 89 d0 c1 e8 06 f3 c3 66
> [ 32.862680] RSP: 0000:ffffc900000ebb90 EFLAGS: 00010206
> [ 32.863309] RAX: 0000000000000000 RBX: ffff88001c67c8a0 RCX: 0000000000000000
> [ 32.864182] RDX: 0000000000000000 RSI: ffff88001c67c000 RDI: ffff88001c67c8a0
> [ 32.865206] RBP: ffff88001c7d03a0 R08: ffff88001c67c8a0 R09: ffff88001c7d0330
> [ 32.866359] R10: ffffffff822c3a98 R11: 0000000000000001 R12: ffff88001c67c000
> [ 32.867213] R13: ffff88001c7d0370 R14: ffffffff8207eb78 R15: ffff88001c67c800
> [ 32.868075] FS: 0000000000000000(0000) GS:ffff88001da00000(0000) knlGS:0000000000000000
> [ 32.868983] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 32.869659] CR2: 0000000000000000 CR3: 000000000220a000 CR4: 00000000000006f0
> [ 32.870599] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [ 32.871598] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> [ 32.872549] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
>
> Since drm_mode_hsync() has the logic to check mode->htotal, I just extend it to cover the case htotal==0.
Signed-off-by: Tina Zhang <tina.zhang@intel.com>
Cc: Adam Jackson <ajax@redhat.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
[danvet: Add additional explanations + cc: stable.]
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/1548228539-3061-1-git-send-email-tina.zhang@intel.com
2019-01-24 13:04:14 +01:00
..
2019-01-16 17:11:47 -05:00
2018-11-24 22:12:54 +01:00
2018-11-02 09:57:27 +00:00
2019-01-03 18:57:57 -08:00
2018-12-25 11:48:26 -08:00
2018-11-01 15:24:22 +01:00
2018-11-19 11:07:52 +10:00
2019-01-09 10:49:31 +01:00
2018-11-22 12:54:38 +10:00
2019-01-03 18:57:57 -08:00
2018-12-14 15:46:15 +09:00
2018-11-01 15:23:58 +01:00
2018-08-27 10:00:03 -04:00
2018-11-05 14:21:21 -05:00
2018-10-04 10:32:14 +10:00
2018-07-03 15:00:42 +02:00
2019-01-17 11:49:51 +02:00
2018-11-05 14:56:04 +01:00
2018-12-03 11:08:22 +08:00
2019-01-15 13:21:32 +01:00
2018-11-05 14:21:21 -05:00
2019-01-03 18:57:57 -08:00
2018-11-24 22:12:54 +01:00
2019-01-18 15:38:18 +10:00
2018-12-03 14:46:30 +02:00
2018-12-03 17:04:48 +01:00
2018-11-28 09:31:07 -08:00
2019-01-14 08:16:18 +01:00
2018-12-28 12:11:50 -08:00
2018-12-25 11:48:26 -08:00
2019-01-13 19:20:45 +01:00
2018-07-04 14:27:01 +02:00
2018-12-05 17:56:16 -05:00
2018-12-11 15:19:42 +01:00
2018-11-24 22:12:54 +01:00
2018-11-13 12:07:18 +01:00
2018-10-25 17:00:28 +02:00
2019-01-22 10:16:22 +01:00
2018-12-06 18:58:32 +01:00
2018-11-01 15:25:41 +01:00
2018-12-04 15:57:42 +01:00
2018-12-21 15:27:58 -05:00
2018-11-24 22:12:54 +01:00
2018-10-23 15:59:01 +02:00
2018-12-07 11:23:05 +10:00
2018-12-05 11:01:11 +01:00
2018-11-05 15:31:51 +00:00
2019-01-14 08:16:19 +01:00
2018-12-04 11:47:27 +01:00
2019-01-01 15:55:29 -08:00
2018-12-18 12:16:13 -05:00
2018-10-05 18:04:10 +02:00
2018-12-07 11:23:05 +10:00
2018-12-24 11:53:50 +01:00
2019-01-10 11:31:58 +01:00
2018-12-05 10:00:35 +01:00
2018-11-26 16:14:27 -05:00
2018-09-11 11:21:30 +01:00
2018-09-13 11:28:12 +02:00
2018-10-17 09:17:33 +02:00
2018-11-20 14:56:18 +01:00
2018-11-29 10:48:31 -05:00
2018-12-06 13:29:09 +10:00
2018-09-14 17:29:47 +01:00
2018-10-05 18:04:10 +02:00
2018-09-10 07:10:36 +02:00
2018-12-07 11:23:05 +10:00
2018-12-24 11:52:43 +01:00
2018-08-22 09:50:16 -07:00
2018-11-22 09:52:27 +01:00
2018-10-11 10:52:35 +02:00
2019-01-10 15:09:35 +02:00
2018-11-28 16:22:17 -05:00
2018-11-29 10:28:49 +10:00
2018-11-27 18:35:17 -08:00
2018-06-28 13:29:07 +10:00
2018-11-02 10:58:20 -07:00
2018-09-14 17:29:47 +01:00
2018-11-19 10:40:33 +10:00
2019-01-10 08:25:36 +01:00
2019-01-03 18:57:57 -08:00
2018-11-20 16:20:13 +02:00
2018-11-02 09:58:10 +00:00
2018-11-20 14:57:25 +01:00
2018-11-02 09:55:27 +00:00
2018-11-20 14:56:18 +01:00
2018-12-25 11:48:26 -08:00
2018-12-20 08:13:29 +01:00
2018-09-14 17:29:47 +01:00
2018-12-25 11:48:26 -08:00
2018-09-14 17:29:47 +01:00
2018-10-16 14:39:25 +02:00
2018-07-25 07:51:05 -04:00
2018-12-06 13:43:56 +10:00
2019-01-10 11:31:58 +01:00
2019-01-24 13:04:14 +01:00
2018-10-05 18:06:49 +02:00
2018-11-29 10:48:31 -05:00
2018-07-13 18:40:28 +02:00
2018-11-15 10:55:30 +01:00
2018-10-04 11:03:34 +10:00
2019-01-08 07:58:37 -05:00
2018-10-05 22:45:19 +02:00
2018-11-29 10:48:31 -05:00
2018-11-22 15:44:05 +01:00
2018-07-30 08:49:41 -04:00
2018-07-13 18:40:27 +02:00
2018-09-14 17:29:47 +01:00
2018-09-14 17:29:47 +01:00
2018-10-30 13:01:50 -07:00
2018-12-05 11:01:11 +01:00
2018-11-30 10:57:18 +01:00
2018-09-14 17:29:47 +01:00
2018-09-04 19:00:32 +01:00
2018-07-16 16:35:27 +01:00
2018-10-03 21:08:21 +02:00
2018-12-06 13:43:56 +10:00