Module Name: src Committed By: snj Date: Sun Jan 29 05:25:03 UTC 2017
Modified Files: src/sys/external/bsd/drm2/dist/drm/ttm [netbsd-7-0]: ttm_tt.c Log Message: 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. XXX pullup-7 To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.6.8.1 src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c diff -u src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c:1.6 src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c:1.6.8.1 --- src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c:1.6 Sun Jul 27 00:40:39 2014 +++ src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c Sun Jan 29 05:25:03 2017 @@ -203,6 +203,9 @@ int ttm_tt_init(struct ttm_tt *ttm, stru 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 @@ int ttm_dma_tt_init(struct ttm_dma_tt *t 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