* [PATCH v2.6.22-rc5] cxgb2: handle possible NULL pointer dereferencing
@ 2007-06-21 12:00 pradeep singh
2007-06-21 12:04 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: pradeep singh @ 2007-06-21 12:00 UTC (permalink / raw)
To: trivial; +Cc: jgarzik, akpm, netdev
Hi,
Chelsio's in kernel 10G driver does not checks the return value from
t1_get_board_info() in cxgb2.c.
t1_get_board_info may return a NULL and we still go on to dereference
it in the for loop without checking for the NULL.
This patch fixes this.
Signed-off-by: Pradeep Singh <pradeep.rautela@gmail.com>
---
drivers/net/chelsio/cxgb2.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 231ce43..edcfeba 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -1023,7 +1023,7 @@ static int __devinit init_one(struct pci_dev *pdev,
mmio_len = pci_resource_len(pdev, 0);
bi = t1_get_board_info(ent->driver_data);
- for (i = 0; i < bi->port_number; ++i) {
+ for (i = 0; bi && i < bi->port_number; ++i) {
struct net_device *netdev;
netdev = alloc_etherdev(adapter ? 0 : sizeof(*adapter));
--
1.4.4.2
Thanks
--
Pradeep
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2.6.22-rc5] cxgb2: handle possible NULL pointer dereferencing
2007-06-21 12:00 [PATCH v2.6.22-rc5] cxgb2: handle possible NULL pointer dereferencing pradeep singh
@ 2007-06-21 12:04 ` Jens Axboe
2007-06-21 12:11 ` pradeep singh
0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2007-06-21 12:04 UTC (permalink / raw)
To: pradeep singh; +Cc: trivial, jgarzik, akpm, netdev
On Thu, Jun 21 2007, pradeep singh wrote:
> Hi,
>
> Chelsio's in kernel 10G driver does not checks the return value from
> t1_get_board_info() in cxgb2.c.
> t1_get_board_info may return a NULL and we still go on to dereference
> it in the for loop without checking for the NULL.
>
> This patch fixes this.
Patch looks odd - bi is dereferenced a number of times after that loop
anyway, so I don't see your patch fixing much.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2.6.22-rc5] cxgb2: handle possible NULL pointer dereferencing
2007-06-21 12:04 ` Jens Axboe
@ 2007-06-21 12:11 ` pradeep singh
2007-06-21 12:34 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: pradeep singh @ 2007-06-21 12:11 UTC (permalink / raw)
To: Jens Axboe; +Cc: trivial, jgarzik, akpm, netdev
Hi
On 6/21/07, Jens Axboe <jens.axboe@oracle.com> wrote:
> On Thu, Jun 21 2007, pradeep singh wrote:
> > Hi,
> >
> > Chelsio's in kernel 10G driver does not checks the return value from
> > t1_get_board_info() in cxgb2.c.
> > t1_get_board_info may return a NULL and we still go on to dereference
> > it in the for loop without checking for the NULL.
> >
> > This patch fixes this.
>
> Patch looks odd - bi is dereferenced a number of times after that loop
> anyway, so I don't see your patch fixing much.
Thanks for pointing that out Jens.
Sorry, i pushed it in a haste :(.
Will check again and resubmit it.
Thanks
--pradeep
[snip]
--
Pradeep
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2.6.22-rc5] cxgb2: handle possible NULL pointer dereferencing
2007-06-21 12:11 ` pradeep singh
@ 2007-06-21 12:34 ` Jens Axboe
2007-06-21 12:42 ` pradeep singh
0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2007-06-21 12:34 UTC (permalink / raw)
To: pradeep singh; +Cc: trivial, jgarzik, akpm, netdev
On Thu, Jun 21 2007, pradeep singh wrote:
> Hi
> On 6/21/07, Jens Axboe <jens.axboe@oracle.com> wrote:
> >On Thu, Jun 21 2007, pradeep singh wrote:
> >> Hi,
> >>
> >> Chelsio's in kernel 10G driver does not checks the return value from
> >> t1_get_board_info() in cxgb2.c.
> >> t1_get_board_info may return a NULL and we still go on to dereference
> >> it in the for loop without checking for the NULL.
> >>
> >> This patch fixes this.
> >
> >Patch looks odd - bi is dereferenced a number of times after that loop
> >anyway, so I don't see your patch fixing much.
> Thanks for pointing that out Jens.
> Sorry, i pushed it in a haste :(.
> Will check again and resubmit it.
You're welcome. The first thing to do is analyze whether a NULL return
from t1_get_board_info() makes any sense. From a quick look, driver_data
should be the index into the t1 pci table. So if t1_get_board_info()
returns NULL, it must be some core bug. So I'd say either don't handle
it, or mark it with BUG_ON(), or do the !bi check and CH_ERR() a warning
and goto out_disable_pdev.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2.6.22-rc5] cxgb2: handle possible NULL pointer dereferencing
2007-06-21 12:34 ` Jens Axboe
@ 2007-06-21 12:42 ` pradeep singh
0 siblings, 0 replies; 5+ messages in thread
From: pradeep singh @ 2007-06-21 12:42 UTC (permalink / raw)
To: Jens Axboe; +Cc: trivial, jgarzik, akpm, netdev
On 6/21/07, Jens Axboe <jens.axboe@oracle.com> wrote:
> On Thu, Jun 21 2007, pradeep singh wrote:
> > Hi
> > On 6/21/07, Jens Axboe <jens.axboe@oracle.com> wrote:
> > >On Thu, Jun 21 2007, pradeep singh wrote:
> > >> Hi,
> > >>
> > >> Chelsio's in kernel 10G driver does not checks the return value from
> > >> t1_get_board_info() in cxgb2.c.
> > >> t1_get_board_info may return a NULL and we still go on to dereference
> > >> it in the for loop without checking for the NULL.
> > >>
> > >> This patch fixes this.
> > >
> > >Patch looks odd - bi is dereferenced a number of times after that loop
> > >anyway, so I don't see your patch fixing much.
> > Thanks for pointing that out Jens.
> > Sorry, i pushed it in a haste :(.
> > Will check again and resubmit it.
>
> You're welcome. The first thing to do is analyze whether a NULL return
> from t1_get_board_info() makes any sense. From a quick look, driver_data
> should be the index into the t1 pci table. So if t1_get_board_info()
> returns NULL, it must be some core bug. So I'd say either don't handle
> it, or mark it with BUG_ON(), or do the !bi check and CH_ERR() a warning
> and goto out_disable_pdev.
Thanks for the advice Jens :).
Yeah this is what i am doing right now.
Will resubmit the patch.
Thanks a lot.
--pradeep
>
> --
> Jens Axboe
>
>
--
Pradeep
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-06-21 12:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21 12:00 [PATCH v2.6.22-rc5] cxgb2: handle possible NULL pointer dereferencing pradeep singh
2007-06-21 12:04 ` Jens Axboe
2007-06-21 12:11 ` pradeep singh
2007-06-21 12:34 ` Jens Axboe
2007-06-21 12:42 ` pradeep singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox