Commit e41409f3 authored by Dave Jones's avatar Dave Jones Committed by Linus Torvalds

[PATCH] missing checks in acorn drivers

Adds missing return values checking of
misc_register(), scsi_register(), request_region()
and does some code cleanup in the process..
parent 081873a5
......@@ -271,9 +271,15 @@ int __init psaux_init(void)
iomd_writeb(0, IOMD_MSECTL);
iomd_writeb(8, IOMD_MSECTL);
if (misc_register(&psaux_mouse))
return -ENODEV;
queue = (struct aux_queue *) kmalloc(sizeof(*queue), GFP_KERNEL);
if (queue == NULL)
return -ENOMEM;
if (misc_register(&psaux_mouse)) {
kfree(queue);
return -ENODEV;
}
memset(queue, 0, sizeof(*queue));
queue->head = queue->tail = 0;
init_waitqueue_head(&queue->proc_list);
......
......@@ -553,15 +553,15 @@ static struct net_device * __init etherh_init_one(struct expansion_card *ec)
ecard_claim(ec);
dev = init_etherdev(NULL, 0);
dev = init_etherdev(NULL, sizeof(struct etherh_priv));
if (!dev)
goto out;
eh = kmalloc(sizeof(struct etherh_priv), GFP_KERNEL);
if (!eh)
goto out_nopriv;
/*
* init_etherdev allocs and zeros dev->priv
*/
eh = dev->priv;
memset(eh, 0, sizeof(struct etherh_priv));
spin_lock_init(&eh->eidev.page_lock);
SET_MODULE_OWNER(dev);
......@@ -695,9 +695,8 @@ static struct net_device * __init etherh_init_one(struct expansion_card *ec)
release:
release_region(dev->base_addr, 16);
free:
kfree(eh);
out_nopriv:
unregister_netdev(dev);
kfree(dev->priv);
kfree(dev);
out:
ecard_release(ec);
......
......@@ -2877,6 +2877,11 @@ int acornscsi_detect(Scsi_Host_Template * tpnt)
ecard_claim(ecs[count]); /* Must claim here - card produces irq on reset */
instance = scsi_register(tpnt, sizeof(AS_Host));
if (!instance) {
ecard_release(ecs[count]);
break;
}
host = (AS_Host *)instance->hostdata;
instance->io_port = ecard_address(ecs[count], ECARD_MEMC, 0);
......
......@@ -140,6 +140,8 @@ int cumanascsi_detect(Scsi_Host_Template * tpnt)
break;
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!instance)
break;
instance->io_port = CUMANA_ADDRESS(ecs[count]);
instance->irq = CUMANA_IRQ(ecs[count]);
......@@ -147,7 +149,11 @@ int cumanascsi_detect(Scsi_Host_Template * tpnt)
ecard_claim(ecs[count]);
instance->n_io_port = 255;
request_region (instance->io_port, instance->n_io_port, "CumanaSCSI-1");
if ( !(request_region (instance->io_port, instance->n_io_port, "CumanaSCSI-1")) ) {
ecard_release(ecs[count]);
scsi_unregister(instance);
break;
}
((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
outb(0x00, instance->io_port - 577);
......
......@@ -103,39 +103,33 @@ int ecoscsi_detect(Scsi_Host_Template * tpnt)
tpnt->proc_name = "ecoscsi";
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!instance)
return 0;
instance->io_port = 0x80ce8000;
instance->n_io_port = 144;
instance->irq = IRQ_NONE;
if (check_region (instance->io_port, instance->n_io_port)) {
scsi_unregister (instance);
return 0;
}
if ( !(request_region(instance->io_port, instance->n_io_port, "ecoscsi")) )
goto unregister_scsi;
ecoscsi_write (instance, MODE_REG, 0x20); /* Is it really SCSI? */
if (ecoscsi_read (instance, MODE_REG) != 0x20) { /* Write to a reg. */
scsi_unregister(instance);
return 0; /* and try to read */
}
if (ecoscsi_read (instance, MODE_REG) != 0x20) /* Write to a reg. */
goto release_reg;
ecoscsi_write( instance, MODE_REG, 0x00 ); /* it back. */
if (ecoscsi_read (instance, MODE_REG) != 0x00) {
scsi_unregister(instance);
return 0;
}
if (ecoscsi_read (instance, MODE_REG) != 0x00)
goto release_reg;
NCR5380_init(instance, 0);
if (request_region (instance->io_port, instance->n_io_port, "ecoscsi") == NULL)
{
scsi_unregister(instance);
return 0;
}
if (instance->irq != IRQ_NONE)
if (instance->irq != IRQ_NONE) {
if (request_irq(instance->irq, do_ecoscsi_intr, SA_INTERRUPT, "ecoscsi", NULL)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
instance->host_no, instance->irq);
instance->irq = IRQ_NONE;
}
}
if (instance->irq != IRQ_NONE) {
printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no);
......@@ -152,7 +146,14 @@ int ecoscsi_detect(Scsi_Host_Template * tpnt)
printk("\nscsi%d:", instance->host_no);
NCR5380_print_options(instance);
printk("\n");
return 1;
release_reg:
release_region(instance->io_port, instance->n_io_port);
unregister_scsi:
scsi_unregister(instance);
return 0
}
int ecoscsi_release (struct Scsi_Host *shpnt)
......
......@@ -126,6 +126,8 @@ int oakscsi_detect(Scsi_Host_Template * tpnt)
break;
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!instance)
break;
instance->io_port = OAK_ADDRESS(ecs[count]);
instance->irq = OAK_IRQ(ecs[count]);
......@@ -133,8 +135,11 @@ int oakscsi_detect(Scsi_Host_Template * tpnt)
ecard_claim(ecs[count]);
instance->n_io_port = 255;
if (!request_region (instance->io_port, instance->n_io_port, "Oak SCSI"))
if (!request_region (instance->io_port, instance->n_io_port, "Oak SCSI")) {
ecard_release(ecs[count]);
scsi_unregister(instance);
break;
}
if (instance->irq != IRQ_NONE)
if (request_irq(instance->irq, do_oakscsi_intr, SA_INTERRUPT, "Oak SCSI", NULL)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment