linux_dsm_epyc7002/drivers/gpu/drm/nouveau
Maarten Lankhorst 35095f7529 drm/nouveau: fix size check for cards without vm
Op 24-07-13 17:55, Dan Carpenter schreef:
> Hello Maarten Lankhorst,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 0108bc8081: "drm/nouveau: do not allow negative sizes for
> now" from Jul 7, 2013, leads to the following Smatch complaint:
>
> drivers/gpu/drm/nouveau/nouveau_bo.c:222 nouveau_bo_new()
> 	 warn: variable dereferenced before check 'drm->client.base.vm' (see line 201)
>
> drivers/gpu/drm/nouveau/nouveau_bo.c
>    200		int type = ttm_bo_type_device;
>    201		int max_size = INT_MAX & ~((1 << drm->client.base.vm->vmm->lpg_shift) - 1);
>                                                  ^^^^^^^^^^^^^^^^^^^
> New dereference.
>
>    202
>    203		if (size <= 0 || size > max_size) {
>    204			nv_warn(drm, "skipped size %x\n", (u32)size);
>    205			return -EINVAL;
>    206		}
>    207
>    208		if (sg)
>    209			type = ttm_bo_type_sg;
>    210
>    211		nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL);
>    212		if (!nvbo)
>    213			return -ENOMEM;
>    214		INIT_LIST_HEAD(&nvbo->head);
>    215		INIT_LIST_HEAD(&nvbo->entry);
>    216		INIT_LIST_HEAD(&nvbo->vma_list);
>    217		nvbo->tile_mode = tile_mode;
>    218		nvbo->tile_flags = tile_flags;
>    219		nvbo->bo.bdev = &drm->ttm.bdev;
>    220
>    221		nvbo->page_shift = 12;
>    222		if (drm->client.base.vm) {
>                     ^^^^^^^^^^^^^^^^^^^
> Old check.
>
>    223			if (!(flags & TTM_PL_FLAG_TT) && size > 256 * 1024)
>    224				nvbo->page_shift = drm->client.base.vm->vmm->lpg_shift;
>
> regards,
> dan carpenter

8<-----
Commit 0108bc8081: "drm/nouveau: do not allow negative sizes for now" broke
older nvidia gpu's that lack a vm. Add an explicit check to handle this.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: konrad wilk <konrad.wilk@oracle.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2013-07-30 13:04:52 +10:00
..
core drm/nv50-/disp: remove dcb_outp_match call, and related variables 2013-07-30 13:04:45 +10:00
dispnv04 drm/nv04/disp: hide all the cruft away in its own little hole 2013-04-26 15:37:51 +10:00
Kconfig drm/nouveau: always select ACPI_VIDEO if ACPI is enabled. 2013-06-28 11:56:22 +10:00
Makefile drm/nvd7/gr: initial support 2013-07-05 13:43:16 +10:00
nouveau_abi16.c drm/nouveau: unpin notify object in chan_fini 2013-06-28 11:55:48 +10:00
nouveau_abi16.h
nouveau_acpi.c
nouveau_acpi.h nouveau: ACPI support depends on X86 and X86_PLATFORM_DEVICES 2013-02-20 16:05:16 +10:00
nouveau_agp.c drm/nouveau: Disable AGP on PowerPC again. 2013-03-04 11:46:12 +10:00
nouveau_agp.h
nouveau_backlight.c drm/nouveau/drm: adding support for backlight control of GT525M (NVC0) 2013-04-26 15:37:45 +10:00
nouveau_bios.c drm/nvd0-/disp: handle case where display engine is missing/disabled 2013-07-01 13:50:50 +10:00
nouveau_bios.h drm/nv04/disp: hide all the cruft away in its own little hole 2013-04-26 15:37:51 +10:00
nouveau_bo.c drm/nouveau: fix size check for cards without vm 2013-07-30 13:04:52 +10:00
nouveau_bo.h drm/nouveau: use prime helpers 2013-02-08 13:39:09 +10:00
nouveau_chan.c drm/nouveau/fb: initialise vram controller as pfb sub-object 2013-07-01 13:44:04 +10:00
nouveau_chan.h
nouveau_connector.c drm/nv04/disp: hide all the cruft away in its own little hole 2013-04-26 15:37:51 +10:00
nouveau_connector.h drm/nouveau/gpio: use event interfaces for interrupt signalling 2013-02-20 16:00:50 +10:00
nouveau_crtc.h
nouveau_debugfs.c drm/nouveau: restore debugfs/vbios.rom support 2013-02-20 20:46:34 +10:00
nouveau_debugfs.h drm/nouveau: restore debugfs/vbios.rom support 2013-02-20 20:46:34 +10:00
nouveau_display.c drm/nouveau: fix some error-path leaks in fbcon handling code 2013-07-10 10:47:28 +10:00
nouveau_display.h drm/nouveau/disp: port vblank handling to event interface 2013-02-20 16:00:46 +10:00
nouveau_dma.c
nouveau_dma.h drm/nouveau/fence/nv84-: put processes to sleep while waiting on fences 2013-02-20 16:00:48 +10:00
nouveau_dp.c drm/nv50-/disp: move DP link training to core and train from supervisor 2013-02-20 16:01:02 +10:00
nouveau_drm.c drm/nouveau: use dedicated channel for async moves on GT/GF chipsets. 2013-07-10 10:48:01 +10:00
nouveau_drm.h drm/nouveau: fix minor thinko causing bo moves to not be async on kepler 2013-07-08 10:52:02 +10:00
nouveau_encoder.h drm/nv04/disp: hide all the cruft away in its own little hole 2013-04-26 15:37:51 +10:00
nouveau_fbcon.c drm/nouveau: fix null pointer dereference in poll_changed 2013-07-30 13:04:19 +10:00
nouveau_fbcon.h
nouveau_fence.c drm/nouveau: bump fence timeout to 15 seconds 2013-07-10 10:48:00 +10:00
nouveau_fence.h drm/nouveau: delay busy bo vma removal until fence signals 2013-07-01 13:50:31 +10:00
nouveau_gem.c drm/nouveau: do not unpin in nouveau_gem_object_del 2013-07-10 10:47:49 +10:00
nouveau_gem.h drm/nouveau: implement prime helper unpin function 2013-06-28 11:55:34 +10:00
nouveau_hwsq.h
nouveau_ioc32.c
nouveau_ioctl.h
nouveau_mem.c drm/nouveau/fb: initialise vram controller as pfb sub-object 2013-07-01 13:44:04 +10:00
nouveau_perf.c
nouveau_pm.c drm/nouveau/hwmon: do not expose a buggy temperature if it is unavailable 2013-03-18 11:15:27 +10:00
nouveau_pm.h
nouveau_prime.c drm/nouveau: implement prime helper unpin function 2013-06-28 11:55:34 +10:00
nouveau_reg.h
nouveau_sgdma.c
nouveau_ttm.c Merge branch 'drm-nouveau-next' of git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-next 2013-07-01 14:10:20 +10:00
nouveau_ttm.h
nouveau_vga.c
nouveau_vga.h
nouveau_volt.c
nv04_fbcon.c
nv04_fence.c drm/nouveau/fence: make internal hooks part of the context 2013-02-20 16:00:53 +10:00
nv04_pm.c drm/nv04/disp: hide all the cruft away in its own little hole 2013-04-26 15:37:51 +10:00
nv10_fence.c drm/nouveau/fence: make internal hooks part of the context 2013-02-20 16:00:53 +10:00
nv10_fence.h drm/nouveau: share fence structures between nv10+ and nv50 implementations 2013-02-20 16:00:34 +10:00
nv17_fence.c drm/nouveau/fence: make internal hooks part of the context 2013-02-20 16:00:53 +10:00
nv40_pm.c drm/nv04/disp: hide all the cruft away in its own little hole 2013-04-26 15:37:51 +10:00
nv50_display.c drm/nv50/kms: fix pin refcnt leaks 2013-07-10 10:47:42 +10:00
nv50_display.h
nv50_fbcon.c
nv50_fence.c drm/nouveau/fence: make internal hooks part of the context 2013-02-20 16:00:53 +10:00
nv50_pm.c drm/nouveau/fb: initialise vram controller as pfb sub-object 2013-07-01 13:44:04 +10:00
nv84_fence.c drm/nv84-/fence: prepare for emit/sync support of sysram sequences 2013-02-20 16:00:53 +10:00
nva3_pm.c drm/nouveau/fb: initialise vram controller as pfb sub-object 2013-07-01 13:44:04 +10:00
nvc0_fbcon.c
nvc0_fence.c drm/nv84-/fence: prepare for emit/sync support of sysram sequences 2013-02-20 16:00:53 +10:00
nvc0_pm.c drm/nouveau/fb: initialise vram controller as pfb sub-object 2013-07-01 13:44:04 +10:00