Serial-5.05
This patch fixes a string corruption bug that occurs
when the probe for PCI cards fails.
In function probe_serial_pci(), if the call to
pci_module_init() fails, the function ensures that
pci_unregister_driver() will not be called on module
exit (rs_fini()). It currently does this by overwriting
the first character of the string pointed to by
serial_pci_driver.name with a null character.
Unfortunately, this happens to be overwriting an
unnamed array of char initialized by the string literal
"serial" and this unnamed array of char is pointed to
by other parts of the driver due to optimization by the
compiler (the C standard refers to this as undefined
behavior).
Since serial_pci_driver.name is a pointer, my patch
just sets this to NULL when pci_module_init() fails.
Function rs_fini() now checks for a NULL pointer rather
than an empty string.
Patch to fix string literal overwrite bug (serial-5.05)
Logged In: YES
user_id=141198
This bug has been fixed in Linux kernel 2.4.7, except that
fix was a one-line change rather than my two line change.
The official fix points serial_pci_driver.name to an empty
string (my fix set it to NULL) so does not need to change
the test in function rs_fini().
"There's more than one way to do it!" as Larry Wall would
say. :-)