From 9622d8acf15601a700cc233659b627a8ac987dfa Mon Sep 17 00:00:00 2001 From: macallan Date: Tue, 13 Nov 2012 20:29:03 +0000 Subject: [PATCH] glyphcache_init(): bail if we don't have enough off-screen memory to be useful --- sys/dev/wscons/wsdisplay_glyphcache.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/dev/wscons/wsdisplay_glyphcache.c b/sys/dev/wscons/wsdisplay_glyphcache.c index 0a88f081ca7e..0d89a76515fe 100644 --- a/sys/dev/wscons/wsdisplay_glyphcache.c +++ b/sys/dev/wscons/wsdisplay_glyphcache.c @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay_glyphcache.c,v 1.4 2012/10/04 10:26:32 macallan Exp $ */ +/* $NetBSD: wsdisplay_glyphcache.c,v 1.5 2012/11/13 20:29:03 macallan Exp $ */ /* * Copyright (c) 2012 Michael Lorenz @@ -75,6 +75,14 @@ glyphcache_init(glyphcache *gc, int first, int lines, int width, buckets = (gc->gc_numcells / 223); if ((buckets * 223) < gc->gc_numcells) buckets++; + + /* + * if we don't have enough video memory to cache at least a few glyphs + * we stop right here + */ + if (buckets < 1) + return ENOMEM; + gc->gc_buckets = kmem_alloc(sizeof(gc_bucket) * buckets, KM_SLEEP); if (gc->gc_buckets == NULL) { aprint_error("%s: can't allocate memory\n", __func__);