Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/sys/external/bsd/drm2/dist/drm/ttm Pull up following revi...



details:   https://anonhg.NetBSD.org/src/rev/72121d018c49
branches:  netbsd-7
changeset: 800117:72121d018c49
user:      snj <snj%NetBSD.org@localhost>
date:      Sun Jan 29 05:24:16 2017 +0000

description:
Pull up following revision(s) (requested by maya in ticket #1350):
        sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c: revision 1.8
Guarantee no zero-size uao/kmem allocations via ttm.
It may be that all callers guarantee no zero-size ttm objects, but I
can't prove that in five minutes of browsing callers.  Rather than
add a KASSERT, lacking proof, we'll add a warning message so that if
it does happen then it happens noisily, but we'll also prevent the
bad consequences of passing zero into uao_create by rounding up to a
harmless nonzero allocation.

diffstat:

 sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c |  6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (23 lines):

diff -r 385221545bf3 -r 72121d018c49 sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c
--- a/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c       Sun Jan 29 05:17:33 2017 +0000
+++ b/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c       Sun Jan 29 05:24:16 2017 +0000
@@ -203,6 +203,9 @@
        ttm->dummy_read_page = dummy_read_page;
        ttm->state = tt_unpopulated;
 #ifdef __NetBSD__
+       WARN(size == 0, "zero-size allocation in %s, please file a NetBSD PR",
+           __func__);  /* paranoia -- can't prove in five minutes */
+       size = MAX(size, 1);
        ttm->swap_storage = uao_create(roundup2(size, PAGE_SIZE), 0);
        uao_set_pgfl(ttm->swap_storage, bus_dmamem_pgfl(bdev->dmat));
 #else
@@ -245,6 +248,9 @@
        ttm->dummy_read_page = dummy_read_page;
        ttm->state = tt_unpopulated;
 #ifdef __NetBSD__
+       WARN(size == 0, "zero-size allocation in %s, please file a NetBSD PR",
+           __func__);  /* paranoia -- can't prove in five minutes */
+       size = MAX(size, 1);
        ttm->swap_storage = uao_create(roundup2(size, PAGE_SIZE), 0);
        uao_set_pgfl(ttm->swap_storage, bus_dmamem_pgfl(bdev->dmat));
 #else



Home | Main Index | Thread Index | Old Index