lkml.org 
[lkml]   [2001]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] catch potential null derefs in drivers/char/ip2main.c (245ac16)
Hi.

(My last mail to dougm@computone.com bounced. Is there another
maintainer for drivers/char/ip2main.c somewhere?)

The patch below tries to avoid dereferencing (potential)
NULL pointers. It was reported by the Stanford team way
back and applies against 245ac16 and 246p6. It could
probably be done nicer but that would take someone that
actually understands this code.

--- linux-245-ac16-clean/drivers/char/ip2main.c Sat May 19 20:58:17 2001
+++ linux-245-ac16/drivers/char/ip2main.c Sun Jun 24 22:37:27 2001
@@ -866,36 +866,38 @@
}

#ifdef CONFIG_DEVFS_FS
- sprintf( name, "ipl%d", i );
- i2BoardPtrTable[i]->devfs_ipl_handle =
- devfs_register (devfs_handle, name,
- DEVFS_FL_DEFAULT,
- IP2_IPL_MAJOR, 4 * i,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
- &ip2_ipl, NULL);
+ if (i2BoardPtrTable[i] && pB) {
+ sprintf( name, "ipl%d", i );
+ i2BoardPtrTable[i]->devfs_ipl_handle =
+ devfs_register (devfs_handle, name,
+ DEVFS_FL_DEFAULT,
+ IP2_IPL_MAJOR, 4 * i,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
+ &ip2_ipl, NULL);

- sprintf( name, "stat%d", i );
- i2BoardPtrTable[i]->devfs_stat_handle =
- devfs_register (devfs_handle, name,
- DEVFS_FL_DEFAULT,
- IP2_IPL_MAJOR, 4 * i + 1,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
- &ip2_ipl, NULL);
+ sprintf( name, "stat%d", i );
+ i2BoardPtrTable[i]->devfs_stat_handle =
+ devfs_register (devfs_handle, name,
+ DEVFS_FL_DEFAULT,
+ IP2_IPL_MAJOR, 4 * i + 1,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
+ &ip2_ipl, NULL);

- for ( box = 0; box < ABS_MAX_BOXES; ++box )
- {
- for ( j = 0; j < ABS_BIGGEST_BOX; ++j )
- {
- if ( pB->i2eChannelMap[box] & (1 << j) )
+ for ( box = 0; box < ABS_MAX_BOXES; ++box )
{
- tty_register_devfs(&ip2_tty_driver,
- 0, j + ABS_BIGGEST_BOX *
- (box+i*ABS_MAX_BOXES));
- tty_register_devfs(&ip2_callout_driver,
- 0, j + ABS_BIGGEST_BOX *
- (box+i*ABS_MAX_BOXES));
+ for ( j = 0; j < ABS_BIGGEST_BOX; ++j )
+ {
+ if ( pB->i2eChannelMap[box] & (1 << j) )
+ {
+ tty_register_devfs(&ip2_tty_driver,
+ 0, j + ABS_BIGGEST_BOX *
+ (box+i*ABS_MAX_BOXES));
+ tty_register_devfs(&ip2_callout_driver,
+ 0, j + ABS_BIGGEST_BOX *
+ (box+i*ABS_MAX_BOXES));
+ }
+ }
}
- }
}
#endif

--
Regards,
Rasmus(rasmus@jaquet.dk)
A chicken and an egg are lying in bed. The chicken is smoking a
cigarette with a satisfied smile on it's face and the egg is frowning
and looking a bit pissed off. The egg mutters, to no-one in particular,
"Well, I guess we answered THAT question..."
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:55    [W:0.037 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site