android_kernel_oneplus_msm8998/drivers/gpu/drm
Tina Zhang f1cd557ecb drm/modes: Prevent division by zero htotal
commit a2fcd5c84f7a7825e028381b10182439067aa90d upstream.

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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-20 10:13:19 +01:00
..
amd mm: replace get_user_pages() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
armada drm/armada: fix colorkey mode property 2018-08-24 13:26:58 +02:00
ast drm/ast: fixed reading monitor EDID not stable issue 2018-12-17 21:55:11 +01:00
atmel-hlcdc drm: atmel-hlcdc: Fix vertical scaling 2016-09-24 10:07:42 +02:00
bochs
bridge
cirrus drm/drivers: add support for using the arch wc mapping API. 2018-09-09 20:04:36 +02:00
exynos mm: replace get_vaddr_frames() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
fsl-dcu
gma500 drm: gma500: fix logic error 2018-12-13 09:21:29 +01:00
i2c drm/bridge: adv7511: Reset registers on hotplug 2018-09-05 09:18:34 +02:00
i810
i915 mm: replace get_user_pages() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
imx drm/imx: imx-ldb: check if channel is enabled before printing warning 2018-09-05 09:18:34 +02:00
mga
mgag200 drm/drivers: add support for using the arch wc mapping API. 2018-09-09 20:04:36 +02:00
msm drm/msm: Grab a vblank reference when waiting for commit_done 2018-12-21 14:09:52 +01:00
nouveau drm/nouveau/fbcon: fix oops without fbdev emulation 2018-11-10 07:41:37 -08:00
omapdrm drm/omap: fix memory barrier bug in DMM driver 2018-11-21 09:27:38 +01:00
panel drm/panel: type promotion bug in s6e8aa0_read_mtp_id() 2018-09-26 08:35:10 +02:00
qxl drm: qxl: Don't alloc fbdev if emulation is not supported 2018-03-22 09:23:19 +01:00
r128
radeon mm: replace get_user_pages() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
rcar-du drm: rcar-du: Fix race condition when disabling planes at CRTC stop 2018-02-16 20:09:37 +01:00
rockchip Revert "drm/rockchip: Allow driver to be shutdown on reboot/kexec" 2018-12-21 14:09:51 +01:00
savage
shmobile
sis
sti drm/sti: sti_vtg: Handle return NULL error from devm_ioremap_nocache 2017-11-21 09:21:19 +01:00
tdfx
tegra
tilcdc
ttm drm/ttm: check the return value of kzalloc 2018-03-03 10:19:44 +01:00
udl udl-kms: fix crash due to uninitialized memory 2018-09-05 09:18:39 +02:00
vc4
vgem
via mm: replace get_user_pages() write/force parameters with gup_flags 2018-12-17 21:55:16 +01:00
virtio virtio-gpu: fix ioctl and expose the fixed status to userspace. 2018-05-30 07:49:02 +02:00
vmwgfx drm/vmwgfx: Fix a buffer object leak 2018-05-16 10:06:48 +02:00
ati_pcigart.c
drm_agpsupport.c
drm_atomic.c drm/atomic: Handling the case when setting old crtc for plane 2018-08-06 16:24:37 +02:00
drm_atomic_helper.c drm/atomic: fix an error code in mode_fixup() 2017-03-15 09:57:15 +08:00
drm_auth.c
drm_bridge.c
drm_bufs.c drm/bufs: Fix Spectre v1 vulnerability 2019-02-20 10:13:03 +01:00
drm_cache.c drm: Restore double clflush on the last partial cacheline 2016-08-20 18:09:23 +02:00
drm_context.c
drm_crtc.c drm: Reject page_flip for !DRIVER_MODESET 2016-09-15 08:27:51 +02:00
drm_crtc_helper.c
drm_crtc_internal.h
drm_debugfs.c
drm_dma.c
drm_dp_helper.c
drm_dp_mst_topology.c drm/dp_mst: Check if primary mstb is null 2018-11-21 09:27:44 +01:00
drm_drv.c drm: drm_minor_register(): Clean up debugfs on failure 2017-11-15 17:13:09 +01:00
drm_edid.c drm/edid: set ELD connector type in drm_edid_to_eld() 2018-03-22 09:23:27 +01:00
drm_edid_load.c
drm_encoder_slave.c
drm_fb_cma_helper.c
drm_fb_helper.c drm/fb-helper: Ignore the value of fb_var_screeninfo.pixclock 2019-01-26 09:42:52 +01:00
drm_flip_work.c
drm_fops.c drm: set FMODE_UNSIGNED_OFFSET for drm files 2018-06-13 16:15:27 +02:00
drm_gem.c drm: Release driver tracking before making the object available again 2017-08-30 10:19:23 +02:00
drm_gem_cma_helper.c
drm_global.c
drm_hashtab.c
drm_info.c
drm_internal.h
drm_ioc32.c drm: Only use compat ioctl for addfb2 on X86/IA64 2016-09-24 10:07:43 +02:00
drm_ioctl.c drm/ioctl: Fix Spectre v1 vulnerabilities 2019-01-13 10:05:27 +01:00
drm_irq.c drm: Defer disabling the vblank IRQ until the next interrupt (for instant-off) 2018-03-22 09:23:20 +01:00
drm_legacy.h
drm_lock.c
drm_memory.c
drm_mipi_dsi.c
drm_mm.c drm: Apply range restriction after color adjustment when allocation 2017-11-30 08:37:27 +00:00
drm_modes.c drm/modes: Prevent division by zero htotal 2019-02-20 10:13:19 +01:00
drm_modeset_lock.c drm: Require __GFP_NOFAIL for the legacy drm_modeset_lock_all 2018-02-25 11:03:35 +01:00
drm_of.c
drm_panel.c
drm_pci.c
drm_plane_helper.c
drm_platform.c
drm_prime.c drm/prime: Pass the right module owner through to dma_buf_export() 2016-10-31 04:13:57 -06:00
drm_probe_helper.c drm: Allow determining if current task is output poll worker 2018-03-18 11:17:48 +01:00
drm_rect.c
drm_scatter.c
drm_sysfs.c
drm_trace.h
drm_trace_points.c
drm_vm.c
drm_vma_manager.c
Kconfig
Makefile