Skip to contentSkip to conversation

Put the check for NULL before the use of a potentially-null value

PATCH In review Frank Sorenson 3 participants 4 messages Jan 10, 2005 – Jan 11, 2005 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Put the check for NULL before the use of a potentially-null value

This patch reorders two lines to check a variable for NULL before using the variable.

Frank
---------------------------------------------------------------------------
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
[email protected]

arch/um/drivers/line.c +1 -1
diff -Naur linux-2.6.10-mm2.orig/arch/um/drivers/line.c linux-2.6.10-mm2/arch/um/drivers/line.c
@@ -593,8 +593,8 @@
 		}
 	}
 	tty  = winch->tty;
-	line = tty->driver_data;
 	if (tty != NULL) {
+		line = tty->driver_data;
 		chan_window_size(&line->chan_list,
 				 &tty->winsize.ws_row, 
 				 &tty->winsize.ws_col);
#1 lore raw
Quoted 4 lines · Frank Sorenson

This patch reorders two lines to check a variable for NULL before using the variable.

diff -Naur linux-2.6.10-mm2.orig/arch/um/drivers/line.c linux-2.6.10-mm2/arch/um/drivers/line.c
--- linux-2.6.10-mm2.orig/arch/um/drivers/line.c 2005-01-10
14:35:20.379815252 -0700
+++ linux-2.6.10-mm2/arch/um/drivers/line.c 2005-01-10 14:35:59.786829555
-0700
@@ -593,8 +593,8 @@

                }
        }
        tty  = winch->tty;
-       line = tty->driver_data;
        if (tty != NULL) {
+               line = tty->driver_data;
                chan_window_size(&line->chan_list,
                                 &tty->winsize.ws_row, 
                                 &tty->winsize.ws_col);

Ok, correct and thanks a lot.

Sorry, a little question: against what tree does it apply?

I cannot apply it locally, but I see that it should apply on top of Gerd Knorr's terminal cleanup patch, which introduces the bug.

I hope I'll not forget it...

Signature · 13 lines
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Blaisorblade wrote:

| On Monday 10 January 2005 22:52, Frank Sorenson wrote:
|
|>This patch reorders two lines to check a variable for NULL before using
|>the variable.
| Ok, correct and thanks a lot.
|
| Sorry, a little question: against what tree does it apply?
|
| I cannot apply it locally, but I see that it should apply on top of Gerd
| Knorr's terminal cleanup patch, which introduces the bug.
|
| I hope I'll not forget it...

It should apply against 2.6.10-mm2 (uml-terminal-cleanup went into -mm2) or anything after (looks like I did the diff from after Jeff Dike's recent slew of patches).

Frank
- --
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB4yacaI0dwg4A47wRAhVGAJsFq+onMrDEOI/1CGPFN6UJNxgi7wCfUT33 FoV3BzZkwxG9h8himxPZ+sw=
=I+np
-----END PGP SIGNATURE-----

-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw
In reply to Blaisorblade
Quoted 5 lines
arch/um/drivers/line.c +1 -1
-       line = tty->driver_data;
        if (tty != NULL) {
+               line = tty->driver_data;

Sorry, a little question: against what tree does it apply?

Any cutting edge tree (both latest -mm and latest Linus -bk snapshot).

Quoted 1 line

I hope I'll not forget it...

I think it can go to andrew morton as-is, it's a ObviouslyCorrect[tm] fix.

Gerd

Signature · 12 lines
#define printk(args...) fprintf(stderr, ## args)



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel