Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/wscons PR/50413: Vicente Chaves: Check the allocattr...
details: https://anonhg.NetBSD.org/src/rev/63264b366d51
branches: trunk
changeset: 341492:63264b366d51
user: christos <christos%NetBSD.org@localhost>
date: Sun Nov 08 16:49:20 2015 +0000
description:
PR/50413: Vicente Chaves: Check the allocattr return and return an error.
diffstat:
sys/dev/wscons/wsdisplay_vcons.c | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
diffs (64 lines):
diff -r 6f2ec0b3b5bb -r 63264b366d51 sys/dev/wscons/wsdisplay_vcons.c
--- a/sys/dev/wscons/wsdisplay_vcons.c Sun Nov 08 16:38:56 2015 +0000
+++ b/sys/dev/wscons/wsdisplay_vcons.c Sun Nov 08 16:49:20 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay_vcons.c,v 1.34 2015/07/19 13:22:42 mlelstv Exp $ */
+/* $NetBSD: wsdisplay_vcons.c,v 1.35 2015/11/08 16:49:20 christos Exp $ */
/*-
* Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.34 2015/07/19 13:22:42 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.35 2015/11/08 16:49:20 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -285,15 +285,21 @@
#else
cnt = ri->ri_rows * ri->ri_cols;
#endif
- scr->scr_attrs = (long *)malloc(cnt * (sizeof(long) +
+ scr->scr_attrs = malloc(cnt * (sizeof(long) +
sizeof(uint32_t)), M_DEVBUF, M_WAITOK);
if (scr->scr_attrs == NULL)
return ENOMEM;
scr->scr_chars = (uint32_t *)&scr->scr_attrs[cnt];
- ri->ri_ops.allocattr(ri, WS_DEFAULT_FG, WS_DEFAULT_BG, 0, defattr);
- scr->scr_defattr = *defattr;
+ i = ri->ri_ops.allocattr(ri, WS_DEFAULT_FG, WS_DEFAULT_BG, 0, defattr);
+ if (i != 0) {
+#ifdef DIAGNOSTIC
+ printf("vcons: error allocating attribute %d\n", i);
+#endif
+ scr->scr_defattr = 0;
+ } else
+ scr->scr_defattr = *defattr;
/*
* fill the attribute buffer with *defattr, chars with 0x20
@@ -1140,6 +1146,7 @@
{
long attr;
struct rasops_info *ri;
+ int error;
KASSERT(scr != NULL && wsc != NULL);
@@ -1152,8 +1159,10 @@
if ((wsc->row >= 0) && (wsc->row < ri->ri_rows) && (wsc->col >= 0) &&
(wsc->col < ri->ri_cols)) {
- ri->ri_ops.allocattr(ri, wsc->foreground, wsc->background,
- wsc->flags, &attr);
+ error = ri->ri_ops.allocattr(ri, wsc->foreground,
+ wsc->background, wsc->flags, &attr);
+ if (error)
+ return error;
vcons_putchar(ri, wsc->row, wsc->col, wsc->letter, attr);
#ifdef VCONS_DEBUG
printf("vcons_putwschar(%d, %d, %x, %lx\n", wsc->row, wsc->col,
Home |
Main Index |
Thread Index |
Old Index