summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2001-01-11 04:29:12 +0000
committerRalf Baechle <ralf@linux-mips.org>2001-01-11 04:29:12 +0000
commit6fc3f3b279f1bf7edfd9e6080906448b0c1079be (patch)
tree8fc3bc7bf43019799a30aa0bbdefdddbe98204f4 /drivers/net
parent55abd6b02bb239d4a84946b76c0128322c582140 (diff)
SGI Seeq8003 driver kmalloc() NULL-check bugfix. From Ingo Molnar.
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/sgiseeq.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 2992457ae..d9bf6395d 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -149,7 +149,7 @@ static inline void seeq_load_eaddr(struct net_device *dev,
#define RCNTCFG_INIT (HPCDMA_OWN | HPCDMA_EORP | HPCDMA_XIE)
#define RCNTINFO_INIT (RCNTCFG_INIT | (PKT_BUF_SZ & HPCDMA_BCNT))
-static void seeq_init_ring(struct net_device *dev)
+static int seeq_init_ring(struct net_device *dev)
{
struct sgiseeq_private *sp = (struct sgiseeq_private *) dev->priv;
volatile struct sgiseeq_init_block *ib = &sp->srings;
@@ -173,6 +173,8 @@ static void seeq_init_ring(struct net_device *dev)
unsigned long buffer;
buffer = (unsigned long) kmalloc(PKT_BUF_SZ, GFP_KERNEL);
+ if (!buffer)
+ return -ENOMEM;
ib->tx_desc[i].buf_vaddr = KSEG1ADDR(buffer);
ib->tx_desc[i].tdma.pbuf = PHYSADDR(buffer);
// flush_cache_all();
@@ -186,6 +188,8 @@ static void seeq_init_ring(struct net_device *dev)
unsigned long buffer;
buffer = (unsigned long) kmalloc(PKT_BUF_SZ, GFP_KERNEL);
+ if (!buffer)
+ return -ENOMEM;
ib->rx_desc[i].buf_vaddr = KSEG1ADDR(buffer);
ib->rx_desc[i].rdma.pbuf = PHYSADDR(buffer);
// flush_cache_all();
@@ -193,6 +197,7 @@ static void seeq_init_ring(struct net_device *dev)
ib->rx_desc[i].rdma.cntinfo = (RCNTINFO_INIT);
}
ib->rx_desc[i - 1].rdma.cntinfo |= (HPCDMA_EOR);
+ return 0;
}
#ifdef DEBUG
@@ -242,13 +247,16 @@ void sgiseeq_dump_rings(void)
#define TSTAT_INIT_EDLC ((TSTAT_INIT_SEEQ) | SEEQ_TCMD_RB2)
#define RDMACFG_INIT (HPC3_ERXDCFG_FRXDC | HPC3_ERXDCFG_FEOP | HPC3_ERXDCFG_FIRQ)
-static void init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
+static int init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
volatile struct sgiseeq_regs *sregs)
{
volatile struct hpc3_ethregs *hregs = sp->hregs;
+ int err;
reset_hpc3_and_seeq(hregs, sregs);
- seeq_init_ring(dev);
+ err = seeq_init_ring(dev);
+ if (err)
+ return err;
/* Setup to field the proper interrupt types. */
if (sp->is_edlc) {
@@ -265,6 +273,7 @@ static void init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
hregs->tx_ndptr = PHYSADDR(&sp->srings.tx_desc[0]);
seeq_go(sp, hregs, sregs);
+ return 0;
}
static inline void record_rx_errors(struct sgiseeq_private *sp,
@@ -439,6 +448,7 @@ static int sgiseeq_open(struct net_device *dev)
struct sgiseeq_private *sp = (struct sgiseeq_private *)dev->priv;
volatile struct sgiseeq_regs *sregs = sp->sregs;
unsigned long flags;
+ int err;
save_flags(flags); cli();
if (request_irq(dev->irq, sgiseeq_interrupt, 0, sgiseeqstr, (void *) dev)) {
@@ -447,7 +457,9 @@ static int sgiseeq_open(struct net_device *dev)
return -EAGAIN;
}
- init_seeq(dev, sp, sregs);
+ err = init_seeq(dev, sp, sregs);
+ if (err)
+ return err;
netif_start_queue(dev);
restore_flags(flags);
@@ -473,8 +485,11 @@ static inline int sgiseeq_reset(struct net_device *dev)
{
struct sgiseeq_private *sp = (struct sgiseeq_private *) dev->priv;
volatile struct sgiseeq_regs *sregs = sp->sregs;
+ int err;
- init_seeq(dev, sp, sregs);
+ err = init_seeq(dev, sp, sregs);
+ if (err)
+ return err;
dev->trans_start = jiffies;
netif_wake_queue(dev);