[rtems commit] bsp/qoriq: Avoid NULL pointer access
Sebastian Huber
sebh at rtems.org
Mon May 27 10:45:20 UTC 2013
Module: rtems
Branch: master
Commit: 9344677cf45db5aac61066caec5cf4fc56c2b018
Changeset: http://git.rtems.org/rtems/commit/?id=9344677cf45db5aac61066caec5cf4fc56c2b018
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue May 21 15:58:12 2013 +0200
bsp/qoriq: Avoid NULL pointer access
---
.../libbsp/powerpc/qoriq/console/console-config.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/c/src/lib/libbsp/powerpc/qoriq/console/console-config.c b/c/src/lib/libbsp/powerpc/qoriq/console/console-config.c
index 3947a27..b1d2847 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/console/console-config.c
+++ b/c/src/lib/libbsp/powerpc/qoriq/console/console-config.c
@@ -187,12 +187,18 @@ console_tbl Console_Configuration_Ports [CONSOLE_COUNT] = {
static void output_char(char c)
{
- const console_fns *con = Console_Port_Tbl [Console_Port_Minor]->pDeviceFns;
-
- if (c == '\n') {
- con->deviceWritePolled((int) Console_Port_Minor, '\r');
+ int minor = (int) Console_Port_Minor;
+ const console_tbl **ct_tbl = Console_Port_Tbl;
+
+ if (ct_tbl != NULL) {
+ const console_fns *cf = ct_tbl[minor]->pDeviceFns;
+
+ if (c == '\n') {
+ (*cf->deviceWritePolled)(minor, '\r');
+ }
+
+ (*cf->deviceWritePolled)(minor, c);
}
- con->deviceWritePolled((int) Console_Port_Minor, c);
}
BSP_output_char_function_type BSP_output_char = output_char;
More information about the vc
mailing list