Skip to contentSkip to conversation

console: Fix warning from clang (and potential crash)

PATCH In review Stefan Weil 3 participants 4 messages Aug 17, 2012 – Aug 30, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 console: Fix warning from clang (and potential crash)

ccc-analyzer reports this warning:

console.c:1090:29: warning: Dereference of null pointer

        if (active_console->cursor_timer) {
                            ^

Function console_select allows active_console to be NULL, but would crash when accessing cursor_timer. Fix this.

---

Please note that I don't have a test case which triggers the crash.

Regards,
Stefan Weil

 console.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
console.c +1 -1
index 4525cc7..f5e8814 100644
@@ -1087,7 +1087,7 @@ void console_select(unsigned int index)
     if (s) {
         DisplayState *ds = s->ds;
 
-        if (active_console->cursor_timer) {
+        if (active_console && active_console->cursor_timer) {
             qemu_del_timer(active_console->cursor_timer);
         }
         active_console = s;
Signature · 1 line
1.7.10
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Stefan Weil

ccc-analyzer reports this warning:

console.c:1090:29: warning: Dereference of null pointer

        if (active_console->cursor_timer) {
                            ^

Function console_select allows active_console to be NULL, but would crash when accessing cursor_timer. Fix this.

---

Please note that I don't have a test case which triggers the crash.

Regards,
Stefan Weil

 console.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
console.c +0 -0
index 4525cc7..f5e8814 100644

console.c void console_select(unsigned int index) · line 1093

Quoted 8 lines
console.c +1 -1
@@ -1087,7 +1087,7 @@ void console_select(unsigned int index)
     if (s) {
         DisplayState *ds = s->ds;
 
-        if (active_console->cursor_timer) {
+        if (active_console && active_console->cursor_timer) {
             qemu_del_timer(active_console->cursor_timer);
         }
         active_console = s;

The only path that could trigger this is console_select() in the absence of any console. Not sure if that is possible, but the above is surely consistent with existing code.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#2 lore raw

Am 17.08.2012 16:10, schrieb Jan Kiszka:

Quoted 41 lines · Stefan Weil
Quoted 28 lines

ccc-analyzer reports this warning:

console.c:1090:29: warning: Dereference of null pointer

         if (active_console->cursor_timer) {
                             ^

Function console_select allows active_console to be NULL, but would crash when accessing cursor_timer. Fix this.

---

Please note that I don't have a test case which triggers the crash.

Regards,
Stefan Weil

  console.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
console.c +0 -0
index 4525cc7..f5e8814 100644

console.c void console_select(unsigned int index) · line 1093

Quoted 8 lines
console.c +1 -1
@@ -1087,7 +1087,7 @@ void console_select(unsigned int index)
      if (s) {
          DisplayState *ds = s->ds;
 
-        if (active_console->cursor_timer) {
+        if (active_console&&  active_console->cursor_timer) {
              qemu_del_timer(active_console->cursor_timer);
          }
          active_console = s;

The only path that could trigger this is console_select() in the absence of any console. Not sure if that is possible, but the above is surely consistent with existing code.

Quoted 5 lines

Jan

Ping? It's still missing in QEMU 1.2.

#3 lore raw
Quoted 42 lines · Stefan Weil

Am 17.08.2012 16:10, schrieb Jan Kiszka:

Quoted 41 lines · Stefan Weil
Quoted 28 lines

ccc-analyzer reports this warning:

console.c:1090:29: warning: Dereference of null pointer

         if (active_console->cursor_timer) {
                             ^

Function console_select allows active_console to be NULL, but would crash when accessing cursor_timer. Fix this.

---

Please note that I don't have a test case which triggers the crash.

Regards,
Stefan Weil

  console.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
console.c +0 -0
index 4525cc7..f5e8814 100644

console.c void console_select(unsigned int index) · line 1093

Quoted 8 lines
console.c +1 -1
@@ -1087,7 +1087,7 @@ void console_select(unsigned int index)
      if (s) {
          DisplayState *ds = s->ds;
 
-        if (active_console->cursor_timer) {
+        if (active_console&&  active_console->cursor_timer) {
              qemu_del_timer(active_console->cursor_timer);
          }
          active_console = s;

The only path that could trigger this is console_select() in the absence of any console. Not sure if that is possible, but the above is surely consistent with existing code.

Quoted 8 lines
Quoted 5 lines

Jan

Ping? It's still missing in QEMU 1.2.

It'll need to wait for 1.3 to open up. I missed it for 1.2-rc2 and at this point, I don't want to commit anything other than actual bug fixes.

Regards,

Anthony Liguori