* [PATCH 2.4] - drivers/pci/pci.c NULL pointer fix.
@ 2004-08-30 15:47 Luiz Fernando N. Capitulino
2004-08-31 10:53 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Luiz Fernando N. Capitulino @ 2004-08-30 15:47 UTC (permalink / raw)
To: marcelo.tosatti; +Cc: linux-kernel
Marcelo,
This is another bug fix: the function pci/pci.c::pci_add_new_bus() does not
check the return of pci_alloc_bus(). If this function returns NULL, `child'
can be utilised.
In the patch bellow I added the check, if the call that pci_scan_bridge()
is doing to pci_alloc_bus() return NULL, pci_scan_bridge() returns `max'
(Greg accepted this fix for 2.6, a while ago).
(against 2.4.28-pre2)
Signed-off-by: Luiz Capitulino <lcapitulino@conectiva.com.br>
drivers/pci/pci.c | 9 +++++++++
1 files changed, 9 insertions(+)
diff -X /home/capitulino/kernels/2.6/dontdiff -Nparu a/drivers/pci/pci.c a~/drivers/pci/pci.c
--- a/drivers/pci/pci.c 2004-08-07 20:26:05.000000000 -0300
+++ a~/drivers/pci/pci.c 2004-08-21 19:04:58.000000000 -0300
@@ -1238,6 +1238,8 @@ struct pci_bus * __devinit pci_add_new_b
* Allocate a new bus, and inherit stuff from the parent..
*/
child = pci_alloc_bus();
+ if (!child)
+ return NULL;
list_add_tail(&child->node, &parent->children);
child->self = dev;
@@ -1291,7 +1293,11 @@ static int __devinit pci_scan_bridge(str
*/
if (pass)
return max;
+
child = pci_add_new_bus(bus, dev, 0);
+ if (!child)
+ return max;
+
child->primary = buses & 0xFF;
child->secondary = (buses >> 8) & 0xFF;
child->subordinate = (buses >> 16) & 0xFF;
@@ -1316,6 +1322,9 @@ static int __devinit pci_scan_bridge(str
pci_write_config_word(dev, PCI_STATUS, 0xffff);
child = pci_add_new_bus(bus, dev, ++max);
+ if (!child)
+ return max;
+
buses = (buses & 0xff000000)
| ((unsigned int)(child->primary) << 0)
| ((unsigned int)(child->secondary) << 8)
--
Luiz Fernando Capitulino
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2.4] - drivers/pci/pci.c NULL pointer fix.
2004-08-30 15:47 [PATCH 2.4] - drivers/pci/pci.c NULL pointer fix Luiz Fernando N. Capitulino
@ 2004-08-31 10:53 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2004-08-31 10:53 UTC (permalink / raw)
To: Luiz Fernando N. Capitulino, greg; +Cc: linux-kernel
Applied,
Thanks.
On Mon, Aug 30, 2004 at 12:47:33PM -0300, Luiz Fernando N. Capitulino wrote:
> Marcelo,
>
> This is another bug fix: the function pci/pci.c::pci_add_new_bus() does not
> check the return of pci_alloc_bus(). If this function returns NULL, `child'
> can be utilised.
>
> In the patch bellow I added the check, if the call that pci_scan_bridge()
> is doing to pci_alloc_bus() return NULL, pci_scan_bridge() returns `max'
> (Greg accepted this fix for 2.6, a while ago).
>
> (against 2.4.28-pre2)
>
>
> Signed-off-by: Luiz Capitulino <lcapitulino@conectiva.com.br>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-08-31 12:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-30 15:47 [PATCH 2.4] - drivers/pci/pci.c NULL pointer fix Luiz Fernando N. Capitulino
2004-08-31 10:53 ` Marcelo Tosatti
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.