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) ...@@ -271,9 +271,15 @@ int __init psaux_init(void)
iomd_writeb(0, IOMD_MSECTL); iomd_writeb(0, IOMD_MSECTL);
iomd_writeb(8, IOMD_MSECTL); iomd_writeb(8, IOMD_MSECTL);
if (misc_register(&psaux_mouse))
return -ENODEV;
queue = (struct aux_queue *) kmalloc(sizeof(*queue), GFP_KERNEL); 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)); memset(queue, 0, sizeof(*queue));
queue->head = queue->tail = 0; queue->head = queue->tail = 0;
init_waitqueue_head(&queue->proc_list); init_waitqueue_head(&queue->proc_list);
......
...@@ -553,15 +553,15 @@ static struct net_device * __init etherh_init_one(struct expansion_card *ec) ...@@ -553,15 +553,15 @@ static struct net_device * __init etherh_init_one(struct expansion_card *ec)
ecard_claim(ec); ecard_claim(ec);
dev = init_etherdev(NULL, 0); dev = init_etherdev(NULL, sizeof(struct etherh_priv));
if (!dev) if (!dev)
goto out; goto out;
eh = kmalloc(sizeof(struct etherh_priv), GFP_KERNEL); /*
if (!eh) * init_etherdev allocs and zeros dev->priv
goto out_nopriv; */
eh = dev->priv;
memset(eh, 0, sizeof(struct etherh_priv));
spin_lock_init(&eh->eidev.page_lock); spin_lock_init(&eh->eidev.page_lock);
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
...@@ -695,9 +695,8 @@ static struct net_device * __init etherh_init_one(struct expansion_card *ec) ...@@ -695,9 +695,8 @@ static struct net_device * __init etherh_init_one(struct expansion_card *ec)
release: release:
release_region(dev->base_addr, 16); release_region(dev->base_addr, 16);
free: free:
kfree(eh);
out_nopriv:
unregister_netdev(dev); unregister_netdev(dev);
kfree(dev->priv);
kfree(dev); kfree(dev);
out: out:
ecard_release(ec); ecard_release(ec);
......
...@@ -2877,6 +2877,11 @@ int acornscsi_detect(Scsi_Host_Template * tpnt) ...@@ -2877,6 +2877,11 @@ int acornscsi_detect(Scsi_Host_Template * tpnt)
ecard_claim(ecs[count]); /* Must claim here - card produces irq on reset */ ecard_claim(ecs[count]); /* Must claim here - card produces irq on reset */
instance = scsi_register(tpnt, sizeof(AS_Host)); instance = scsi_register(tpnt, sizeof(AS_Host));
if (!instance) {
ecard_release(ecs[count]);
break;
}
host = (AS_Host *)instance->hostdata; host = (AS_Host *)instance->hostdata;
instance->io_port = ecard_address(ecs[count], ECARD_MEMC, 0); instance->io_port = ecard_address(ecs[count], ECARD_MEMC, 0);
......
...@@ -140,6 +140,8 @@ int cumanascsi_detect(Scsi_Host_Template * tpnt) ...@@ -140,6 +140,8 @@ int cumanascsi_detect(Scsi_Host_Template * tpnt)
break; break;
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!instance)
break;
instance->io_port = CUMANA_ADDRESS(ecs[count]); instance->io_port = CUMANA_ADDRESS(ecs[count]);
instance->irq = CUMANA_IRQ(ecs[count]); instance->irq = CUMANA_IRQ(ecs[count]);
...@@ -147,7 +149,11 @@ int cumanascsi_detect(Scsi_Host_Template * tpnt) ...@@ -147,7 +149,11 @@ int cumanascsi_detect(Scsi_Host_Template * tpnt)
ecard_claim(ecs[count]); ecard_claim(ecs[count]);
instance->n_io_port = 255; 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; ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
outb(0x00, instance->io_port - 577); outb(0x00, instance->io_port - 577);
......
...@@ -98,61 +98,62 @@ void ecoscsi_setup(char *str, int *ints) { ...@@ -98,61 +98,62 @@ void ecoscsi_setup(char *str, int *ints) {
int ecoscsi_detect(Scsi_Host_Template * tpnt) int ecoscsi_detect(Scsi_Host_Template * tpnt)
{ {
struct Scsi_Host *instance; struct Scsi_Host *instance;
tpnt->proc_name = "ecoscsi"; tpnt->proc_name = "ecoscsi";
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
instance->io_port = 0x80ce8000; if (!instance)
instance->n_io_port = 144; return 0;
instance->irq = IRQ_NONE;
if (check_region (instance->io_port, instance->n_io_port)) { instance->io_port = 0x80ce8000;
scsi_unregister (instance); instance->n_io_port = 144;
return 0; instance->irq = IRQ_NONE;
}
ecoscsi_write (instance, MODE_REG, 0x20); /* Is it really SCSI? */ if ( !(request_region(instance->io_port, instance->n_io_port, "ecoscsi")) )
if (ecoscsi_read (instance, MODE_REG) != 0x20) { /* Write to a reg. */ goto unregister_scsi;
scsi_unregister(instance);
return 0; /* and try to read */
}
ecoscsi_write( instance, MODE_REG, 0x00 ); /* it back. */
if (ecoscsi_read (instance, MODE_REG) != 0x00) {
scsi_unregister(instance);
return 0;
}
NCR5380_init(instance, 0); ecoscsi_write (instance, MODE_REG, 0x20); /* Is it really SCSI? */
if (request_region (instance->io_port, instance->n_io_port, "ecoscsi") == NULL) if (ecoscsi_read (instance, MODE_REG) != 0x20) /* Write to a reg. */
{ goto release_reg;
scsi_unregister(instance);
return 0; ecoscsi_write( instance, MODE_REG, 0x00 ); /* it back. */
} if (ecoscsi_read (instance, MODE_REG) != 0x00)
goto release_reg;
if (instance->irq != IRQ_NONE) NCR5380_init(instance, 0);
if (request_irq(instance->irq, do_ecoscsi_intr, SA_INTERRUPT, "ecoscsi", NULL)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n", if (instance->irq != IRQ_NONE) {
instance->host_no, instance->irq); if (request_irq(instance->irq, do_ecoscsi_intr, SA_INTERRUPT, "ecoscsi", NULL)) {
instance->irq = IRQ_NONE; printk("scsi%d: IRQ%d not free, interrupts disabled\n",
instance->host_no, instance->irq);
instance->irq = IRQ_NONE;
}
} }
if (instance->irq != IRQ_NONE) { if (instance->irq != IRQ_NONE) {
printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no); printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no);
printk("scsi%d: that the board had an interrupt!\n", instance->host_no); printk("scsi%d: that the board had an interrupt!\n", instance->host_no);
} }
printk("scsi%d: at port %X irq", instance->host_no, instance->io_port); printk("scsi%d: at port %X irq", instance->host_no, instance->io_port);
if (instance->irq == IRQ_NONE) if (instance->irq == IRQ_NONE)
printk ("s disabled"); printk ("s disabled");
else else
printk (" %d", instance->irq); printk (" %d", instance->irq);
printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
CAN_QUEUE, CMD_PER_LUN, ECOSCSI_PUBLIC_RELEASE); CAN_QUEUE, CMD_PER_LUN, ECOSCSI_PUBLIC_RELEASE);
printk("\nscsi%d:", instance->host_no); printk("\nscsi%d:", instance->host_no);
NCR5380_print_options(instance); NCR5380_print_options(instance);
printk("\n"); printk("\n");
return 1;
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) int ecoscsi_release (struct Scsi_Host *shpnt)
......
...@@ -126,6 +126,8 @@ int oakscsi_detect(Scsi_Host_Template * tpnt) ...@@ -126,6 +126,8 @@ int oakscsi_detect(Scsi_Host_Template * tpnt)
break; break;
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
if (!instance)
break;
instance->io_port = OAK_ADDRESS(ecs[count]); instance->io_port = OAK_ADDRESS(ecs[count]);
instance->irq = OAK_IRQ(ecs[count]); instance->irq = OAK_IRQ(ecs[count]);
...@@ -133,8 +135,11 @@ int oakscsi_detect(Scsi_Host_Template * tpnt) ...@@ -133,8 +135,11 @@ int oakscsi_detect(Scsi_Host_Template * tpnt)
ecard_claim(ecs[count]); ecard_claim(ecs[count]);
instance->n_io_port = 255; 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; break;
}
if (instance->irq != IRQ_NONE) if (instance->irq != IRQ_NONE)
if (request_irq(instance->irq, do_oakscsi_intr, SA_INTERRUPT, "Oak SCSI", NULL)) { 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