Commit 41f96935 authored by Burman Yan's avatar Burman Yan Committed by Linus Torvalds

[PATCH] isdn: replace kmalloc+memset with kzalloc

Acked-by: default avatarKarsten Keil <kkeil@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0b2dd130
...@@ -573,12 +573,11 @@ act2000_alloccard(int bus, int port, int irq, char *id) ...@@ -573,12 +573,11 @@ act2000_alloccard(int bus, int port, int irq, char *id)
{ {
int i; int i;
act2000_card *card; act2000_card *card;
if (!(card = (act2000_card *) kmalloc(sizeof(act2000_card), GFP_KERNEL))) { if (!(card = kzalloc(sizeof(act2000_card), GFP_KERNEL))) {
printk(KERN_WARNING printk(KERN_WARNING
"act2000: (%s) Could not allocate card-struct.\n", id); "act2000: (%s) Could not allocate card-struct.\n", id);
return; return;
} }
memset((char *) card, 0, sizeof(act2000_card));
spin_lock_init(&card->lock); spin_lock_init(&card->lock);
spin_lock_init(&card->mnlock); spin_lock_init(&card->mnlock);
skb_queue_head_init(&card->sndq); skb_queue_head_init(&card->sndq);
......
...@@ -215,13 +215,12 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci) ...@@ -215,13 +215,12 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)
unsigned int minor = 0; unsigned int minor = 0;
unsigned long flags; unsigned long flags;
mp = kmalloc(sizeof(*mp), GFP_ATOMIC); mp = kzalloc(sizeof(*mp), GFP_ATOMIC);
if (!mp) { if (!mp) {
printk(KERN_ERR "capi: can't alloc capiminor\n"); printk(KERN_ERR "capi: can't alloc capiminor\n");
return NULL; return NULL;
} }
memset(mp, 0, sizeof(struct capiminor));
mp->ap = ap; mp->ap = ap;
mp->ncci = ncci; mp->ncci = ncci;
mp->msgid = 0; mp->msgid = 0;
...@@ -304,10 +303,9 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) ...@@ -304,10 +303,9 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci)
struct capiminor *mp = NULL; struct capiminor *mp = NULL;
#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
np = kmalloc(sizeof(*np), GFP_ATOMIC); np = kzalloc(sizeof(*np), GFP_ATOMIC);
if (!np) if (!np)
return NULL; return NULL;
memset(np, 0, sizeof(struct capincci));
np->ncci = ncci; np->ncci = ncci;
np->cdev = cdev; np->cdev = cdev;
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
...@@ -384,10 +382,9 @@ static struct capidev *capidev_alloc(void) ...@@ -384,10 +382,9 @@ static struct capidev *capidev_alloc(void)
struct capidev *cdev; struct capidev *cdev;
unsigned long flags; unsigned long flags;
cdev = kmalloc(sizeof(*cdev), GFP_KERNEL); cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
if (!cdev) if (!cdev)
return NULL; return NULL;
memset(cdev, 0, sizeof(struct capidev));
init_MUTEX(&cdev->ncci_list_sem); init_MUTEX(&cdev->ncci_list_sem);
skb_queue_head_init(&cdev->recvqueue); skb_queue_head_init(&cdev->recvqueue);
......
...@@ -334,12 +334,11 @@ static capidrv_plci *new_plci(capidrv_contr * card, int chan) ...@@ -334,12 +334,11 @@ static capidrv_plci *new_plci(capidrv_contr * card, int chan)
{ {
capidrv_plci *plcip; capidrv_plci *plcip;
plcip = (capidrv_plci *) kmalloc(sizeof(capidrv_plci), GFP_ATOMIC); plcip = kzalloc(sizeof(capidrv_plci), GFP_ATOMIC);
if (plcip == 0) if (plcip == 0)
return NULL; return NULL;
memset(plcip, 0, sizeof(capidrv_plci));
plcip->state = ST_PLCI_NONE; plcip->state = ST_PLCI_NONE;
plcip->plci = 0; plcip->plci = 0;
plcip->msgid = 0; plcip->msgid = 0;
...@@ -404,12 +403,11 @@ static inline capidrv_ncci *new_ncci(capidrv_contr * card, ...@@ -404,12 +403,11 @@ static inline capidrv_ncci *new_ncci(capidrv_contr * card,
{ {
capidrv_ncci *nccip; capidrv_ncci *nccip;
nccip = (capidrv_ncci *) kmalloc(sizeof(capidrv_ncci), GFP_ATOMIC); nccip = kzalloc(sizeof(capidrv_ncci), GFP_ATOMIC);
if (nccip == 0) if (nccip == 0)
return NULL; return NULL;
memset(nccip, 0, sizeof(capidrv_ncci));
nccip->ncci = ncci; nccip->ncci = ncci;
nccip->state = ST_NCCI_NONE; nccip->state = ST_NCCI_NONE;
nccip->plcip = plcip; nccip->plcip = plcip;
...@@ -2005,12 +2003,11 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) ...@@ -2005,12 +2003,11 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)
printk(KERN_WARNING "capidrv: (%s) Could not reserve module\n", id); printk(KERN_WARNING "capidrv: (%s) Could not reserve module\n", id);
return -1; return -1;
} }
if (!(card = (capidrv_contr *) kmalloc(sizeof(capidrv_contr), GFP_ATOMIC))) { if (!(card = kzalloc(sizeof(capidrv_contr), GFP_ATOMIC))) {
printk(KERN_WARNING printk(KERN_WARNING
"capidrv: (%s) Could not allocate contr-struct.\n", id); "capidrv: (%s) Could not allocate contr-struct.\n", id);
return -1; return -1;
} }
memset(card, 0, sizeof(capidrv_contr));
card->owner = THIS_MODULE; card->owner = THIS_MODULE;
init_timer(&card->listentimer); init_timer(&card->listentimer);
strcpy(card->name, id); strcpy(card->name, id);
......
...@@ -121,10 +121,9 @@ static int avmcs_probe(struct pcmcia_device *p_dev) ...@@ -121,10 +121,9 @@ static int avmcs_probe(struct pcmcia_device *p_dev)
p_dev->conf.Present = PRESENT_OPTION; p_dev->conf.Present = PRESENT_OPTION;
/* Allocate space for private device-specific data */ /* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL); local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
if (!local) if (!local)
goto err; goto err;
memset(local, 0, sizeof(local_info_t));
p_dev->priv = local; p_dev->priv = local;
return avmcs_config(p_dev); return avmcs_config(p_dev);
......
...@@ -65,18 +65,15 @@ avmcard *b1_alloc_card(int nr_controllers) ...@@ -65,18 +65,15 @@ avmcard *b1_alloc_card(int nr_controllers)
avmctrl_info *cinfo; avmctrl_info *cinfo;
int i; int i;
card = kmalloc(sizeof(*card), GFP_KERNEL); card = kzalloc(sizeof(*card), GFP_KERNEL);
if (!card) if (!card)
return NULL; return NULL;
memset(card, 0, sizeof(*card)); cinfo = kzalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL);
cinfo = kmalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL);
if (!cinfo) { if (!cinfo) {
kfree(card); kfree(card);
return NULL; return NULL;
} }
memset(cinfo, 0, sizeof(*cinfo) * nr_controllers);
card->ctrlinfo = cinfo; card->ctrlinfo = cinfo;
for (i = 0; i < nr_controllers; i++) { for (i = 0; i < nr_controllers; i++) {
...@@ -718,12 +715,11 @@ avmcard_dma_alloc(char *name, struct pci_dev *pdev, long rsize, long ssize) ...@@ -718,12 +715,11 @@ avmcard_dma_alloc(char *name, struct pci_dev *pdev, long rsize, long ssize)
avmcard_dmainfo *p; avmcard_dmainfo *p;
void *buf; void *buf;
p = kmalloc(sizeof(avmcard_dmainfo), GFP_KERNEL); p = kzalloc(sizeof(avmcard_dmainfo), GFP_KERNEL);
if (!p) { if (!p) {
printk(KERN_WARNING "%s: no memory.\n", name); printk(KERN_WARNING "%s: no memory.\n", name);
goto err; goto err;
} }
memset(p, 0, sizeof(avmcard_dmainfo));
p->recvbuf.size = rsize; p->recvbuf.size = rsize;
buf = pci_alloc_consistent(pdev, rsize, &p->recvbuf.dmaaddr); buf = pci_alloc_consistent(pdev, rsize, &p->recvbuf.dmaaddr);
......
...@@ -123,11 +123,10 @@ static int avma1cs_probe(struct pcmcia_device *p_dev) ...@@ -123,11 +123,10 @@ static int avma1cs_probe(struct pcmcia_device *p_dev)
DEBUG(0, "avma1cs_attach()\n"); DEBUG(0, "avma1cs_attach()\n");
/* Allocate space for private device-specific data */ /* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL); local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
if (!local) if (!local)
return -ENOMEM; return -ENOMEM;
memset(local, 0, sizeof(local_info_t));
p_dev->priv = local; p_dev->priv = local;
/* The io structure describes IO port mapping */ /* The io structure describes IO port mapping */
......
...@@ -869,14 +869,13 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow ...@@ -869,14 +869,13 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
struct IsdnCard *card = cards + cardnr; struct IsdnCard *card = cards + cardnr;
struct IsdnCardState *cs; struct IsdnCardState *cs;
cs = kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC); cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
if (!cs) { if (!cs) {
printk(KERN_WARNING printk(KERN_WARNING
"HiSax: No memory for IsdnCardState(card %d)\n", "HiSax: No memory for IsdnCardState(card %d)\n",
cardnr + 1); cardnr + 1);
goto out; goto out;
} }
memset(cs, 0, sizeof(struct IsdnCardState));
card->cs = cs; card->cs = cs;
spin_lock_init(&cs->statlock); spin_lock_init(&cs->statlock);
spin_lock_init(&cs->lock); spin_lock_init(&cs->lock);
......
...@@ -146,9 +146,8 @@ static int elsa_cs_probe(struct pcmcia_device *link) ...@@ -146,9 +146,8 @@ static int elsa_cs_probe(struct pcmcia_device *link)
DEBUG(0, "elsa_cs_attach()\n"); DEBUG(0, "elsa_cs_attach()\n");
/* Allocate space for private device-specific data */ /* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL); local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
if (!local) return -ENOMEM; if (!local) return -ENOMEM;
memset(local, 0, sizeof(local_info_t));
local->p_dev = link; local->p_dev = link;
link->priv = local; link->priv = local;
......
...@@ -26,12 +26,10 @@ FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount) ...@@ -26,12 +26,10 @@ FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount)
int i; int i;
fsm->jumpmatrix = (FSMFNPTR *) fsm->jumpmatrix = (FSMFNPTR *)
kmalloc(sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL); kzalloc(sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL);
if (!fsm->jumpmatrix) if (!fsm->jumpmatrix)
return -ENOMEM; return -ENOMEM;
memset(fsm->jumpmatrix, 0, sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count);
for (i = 0; i < fncount; i++) for (i = 0; i < fncount; i++)
if ((fnlist[i].state>=fsm->state_count) || (fnlist[i].event>=fsm->event_count)) { if ((fnlist[i].state>=fsm->state_count) || (fnlist[i].event>=fsm->event_count)) {
printk(KERN_ERR "FsmNew Error line %d st(%ld/%ld) ev(%ld/%ld)\n", printk(KERN_ERR "FsmNew Error line %d st(%ld/%ld) ev(%ld/%ld)\n",
......
...@@ -1591,11 +1591,10 @@ hfc4s8s_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1591,11 +1591,10 @@ hfc4s8s_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
hfc4s8s_param *driver_data = (hfc4s8s_param *) ent->driver_data; hfc4s8s_param *driver_data = (hfc4s8s_param *) ent->driver_data;
hfc4s8s_hw *hw; hfc4s8s_hw *hw;
if (!(hw = kmalloc(sizeof(hfc4s8s_hw), GFP_ATOMIC))) { if (!(hw = kzalloc(sizeof(hfc4s8s_hw), GFP_ATOMIC))) {
printk(KERN_ERR "No kmem for HFC-4S/8S card\n"); printk(KERN_ERR "No kmem for HFC-4S/8S card\n");
return (err); return (err);
} }
memset(hw, 0, sizeof(hfc4s8s_hw));
hw->pdev = pdev; hw->pdev = pdev;
err = pci_enable_device(pdev); err = pci_enable_device(pdev);
......
...@@ -1481,9 +1481,8 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -1481,9 +1481,8 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
iface = iface_used; iface = iface_used;
if (! if (!
(context = (context =
kmalloc(sizeof(hfcusb_data), GFP_KERNEL))) kzalloc(sizeof(hfcusb_data), GFP_KERNEL)))
return (-ENOMEM); /* got no mem */ return (-ENOMEM); /* got no mem */
memset(context, 0, sizeof(hfcusb_data));
ep = iface->endpoint; ep = iface->endpoint;
vcf = validconf[small_match]; vcf = validconf[small_match];
......
...@@ -841,12 +841,10 @@ new_adapter(void) ...@@ -841,12 +841,10 @@ new_adapter(void)
struct hisax_b_if *b_if[2]; struct hisax_b_if *b_if[2];
int i; int i;
adapter = kmalloc(sizeof(struct fritz_adapter), GFP_KERNEL); adapter = kzalloc(sizeof(struct fritz_adapter), GFP_KERNEL);
if (!adapter) if (!adapter)
return NULL; return NULL;
memset(adapter, 0, sizeof(struct fritz_adapter));
adapter->isac.hisax_d_if.owner = THIS_MODULE; adapter->isac.hisax_d_if.owner = THIS_MODULE;
adapter->isac.hisax_d_if.ifc.priv = &adapter->isac; adapter->isac.hisax_d_if.ifc.priv = &adapter->isac;
adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1; adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1;
......
...@@ -155,9 +155,8 @@ static int sedlbauer_probe(struct pcmcia_device *link) ...@@ -155,9 +155,8 @@ static int sedlbauer_probe(struct pcmcia_device *link)
DEBUG(0, "sedlbauer_attach()\n"); DEBUG(0, "sedlbauer_attach()\n");
/* Allocate space for private device-specific data */ /* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL); local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
if (!local) return -ENOMEM; if (!local) return -ENOMEM;
memset(local, 0, sizeof(local_info_t));
local->cardnr = -1; local->cardnr = -1;
local->p_dev = link; local->p_dev = link;
......
...@@ -69,12 +69,10 @@ static int probe_st5481(struct usb_interface *intf, ...@@ -69,12 +69,10 @@ static int probe_st5481(struct usb_interface *intf,
le16_to_cpu(dev->descriptor.idProduct), le16_to_cpu(dev->descriptor.idProduct),
number_of_leds); number_of_leds);
adapter = kmalloc(sizeof(struct st5481_adapter), GFP_KERNEL); adapter = kzalloc(sizeof(struct st5481_adapter), GFP_KERNEL);
if (!adapter) if (!adapter)
return -ENOMEM; return -ENOMEM;
memset(adapter, 0, sizeof(struct st5481_adapter));
adapter->number_of_leds = number_of_leds; adapter->number_of_leds = number_of_leds;
adapter->usb_dev = dev; adapter->usb_dev = dev;
......
...@@ -137,9 +137,8 @@ static int teles_probe(struct pcmcia_device *link) ...@@ -137,9 +137,8 @@ static int teles_probe(struct pcmcia_device *link)
DEBUG(0, "teles_attach()\n"); DEBUG(0, "teles_attach()\n");
/* Allocate space for private device-specific data */ /* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL); local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
if (!local) return -ENOMEM; if (!local) return -ENOMEM;
memset(local, 0, sizeof(local_info_t));
local->cardnr = -1; local->cardnr = -1;
local->p_dev = link; local->p_dev = link;
......
...@@ -745,12 +745,11 @@ hycapi_capi_create(hysdn_card *card) ...@@ -745,12 +745,11 @@ hycapi_capi_create(hysdn_card *card)
return 1; return 1;
} }
if (!card->hyctrlinfo) { if (!card->hyctrlinfo) {
cinfo = (hycapictrl_info *) kmalloc(sizeof(hycapictrl_info), GFP_ATOMIC); cinfo = kzalloc(sizeof(hycapictrl_info), GFP_ATOMIC);
if (!cinfo) { if (!cinfo) {
printk(KERN_WARNING "HYSDN: no memory for capi-ctrl.\n"); printk(KERN_WARNING "HYSDN: no memory for capi-ctrl.\n");
return -ENOMEM; return -ENOMEM;
} }
memset(cinfo, 0, sizeof(hycapictrl_info));
card->hyctrlinfo = cinfo; card->hyctrlinfo = cinfo;
cinfo->card = card; cinfo->card = card;
spin_lock_init(&cinfo->lock); spin_lock_init(&cinfo->lock);
......
...@@ -278,14 +278,13 @@ pof_write_open(hysdn_card * card, unsigned char **bufp) ...@@ -278,14 +278,13 @@ pof_write_open(hysdn_card * card, unsigned char **bufp)
return (-ERR_ALREADY_BOOT); /* boot already active */ return (-ERR_ALREADY_BOOT); /* boot already active */
} }
/* error no mem available */ /* error no mem available */
if (!(boot = kmalloc(sizeof(struct boot_data), GFP_KERNEL))) { if (!(boot = kzalloc(sizeof(struct boot_data), GFP_KERNEL))) {
if (card->debug_flags & LOG_MEM_ERR) if (card->debug_flags & LOG_MEM_ERR)
hysdn_addlog(card, "POF open: unable to allocate mem"); hysdn_addlog(card, "POF open: unable to allocate mem");
return (-EFAULT); return (-EFAULT);
} }
card->boot = boot; card->boot = boot;
card->state = CARD_STATE_BOOTING; card->state = CARD_STATE_BOOTING;
memset(boot, 0, sizeof(struct boot_data));
card->stopcard(card); /* first stop the card */ card->stopcard(card); /* first stop the card */
if (card->testram(card)) { if (card->testram(card)) {
......
...@@ -81,11 +81,10 @@ search_cards(void) ...@@ -81,11 +81,10 @@ search_cards(void)
if (pci_enable_device(akt_pcidev)) if (pci_enable_device(akt_pcidev))
continue; continue;
if (!(card = kmalloc(sizeof(hysdn_card), GFP_KERNEL))) { if (!(card = kzalloc(sizeof(hysdn_card), GFP_KERNEL))) {
printk(KERN_ERR "HYSDN: unable to alloc device mem \n"); printk(KERN_ERR "HYSDN: unable to alloc device mem \n");
return; return;
} }
memset(card, 0, sizeof(hysdn_card));
card->myid = cardmax; /* set own id */ card->myid = cardmax; /* set own id */
card->bus = akt_pcidev->bus->number; card->bus = akt_pcidev->bus->number;
card->devfn = akt_pcidev->devfn; /* slot + function */ card->devfn = akt_pcidev->devfn; /* slot + function */
......
...@@ -278,11 +278,10 @@ hysdn_net_create(hysdn_card * card) ...@@ -278,11 +278,10 @@ hysdn_net_create(hysdn_card * card)
return (-ENOMEM); return (-ENOMEM);
} }
hysdn_net_release(card); /* release an existing net device */ hysdn_net_release(card); /* release an existing net device */
if ((dev = kmalloc(sizeof(struct net_local), GFP_KERNEL)) == NULL) { if ((dev = kzalloc(sizeof(struct net_local), GFP_KERNEL)) == NULL) {
printk(KERN_WARNING "HYSDN: unable to allocate mem\n"); printk(KERN_WARNING "HYSDN: unable to allocate mem\n");
return (-ENOMEM); return (-ENOMEM);
} }
memset(dev, 0, sizeof(struct net_local)); /* clean the structure */
spin_lock_init(&((struct net_local *) dev)->lock); spin_lock_init(&((struct net_local *) dev)->lock);
......
...@@ -405,8 +405,7 @@ hysdn_proclog_init(hysdn_card * card) ...@@ -405,8 +405,7 @@ hysdn_proclog_init(hysdn_card * card)
/* create a cardlog proc entry */ /* create a cardlog proc entry */
if ((pd = (struct procdata *) kmalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) { if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
memset(pd, 0, sizeof(struct procdata));
sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid); sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
if ((pd->log = create_proc_entry(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry)) != NULL) { if ((pd->log = create_proc_entry(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry)) != NULL) {
pd->log->proc_fops = &log_fops; pd->log->proc_fops = &log_fops;
......
...@@ -331,12 +331,10 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) ...@@ -331,12 +331,10 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
* Allocate the main control structure for this instance. * Allocate the main control structure for this instance.
*/ */
maxmaxcode = MAXCODE(bits); maxmaxcode = MAXCODE(bits);
db = (struct bsd_db *) kmalloc (sizeof (struct bsd_db),GFP_KERNEL); db = kzalloc (sizeof (struct bsd_db),GFP_KERNEL);
if (!db) if (!db)
return NULL; return NULL;
memset (db, 0, sizeof(struct bsd_db));
db->xmit = data->flags & IPPP_COMP_FLAG_XMIT; db->xmit = data->flags & IPPP_COMP_FLAG_XMIT;
decomp = db->xmit ? 0 : 1; decomp = db->xmit ? 0 : 1;
......
...@@ -2072,21 +2072,19 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) ...@@ -2072,21 +2072,19 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding)
if ((adding) && (d->rcverr)) if ((adding) && (d->rcverr))
kfree(d->rcverr); kfree(d->rcverr);
if (!(d->rcverr = kmalloc(sizeof(int) * m, GFP_ATOMIC))) { if (!(d->rcverr = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n"); printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n");
return -1; return -1;
} }
memset((char *) d->rcverr, 0, sizeof(int) * m);
if ((adding) && (d->rcvcount)) if ((adding) && (d->rcvcount))
kfree(d->rcvcount); kfree(d->rcvcount);
if (!(d->rcvcount = kmalloc(sizeof(int) * m, GFP_ATOMIC))) { if (!(d->rcvcount = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n"); printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n");
if (!adding) if (!adding)
kfree(d->rcverr); kfree(d->rcverr);
return -1; return -1;
} }
memset((char *) d->rcvcount, 0, sizeof(int) * m);
if ((adding) && (d->rpqueue)) { if ((adding) && (d->rpqueue)) {
for (j = 0; j < d->channels; j++) for (j = 0; j < d->channels; j++)
...@@ -2226,11 +2224,10 @@ register_isdn(isdn_if * i) ...@@ -2226,11 +2224,10 @@ register_isdn(isdn_if * i)
printk(KERN_WARNING "register_isdn: No write routine given.\n"); printk(KERN_WARNING "register_isdn: No write routine given.\n");
return 0; return 0;
} }
if (!(d = kmalloc(sizeof(isdn_driver_t), GFP_KERNEL))) { if (!(d = kzalloc(sizeof(isdn_driver_t), GFP_KERNEL))) {
printk(KERN_WARNING "register_isdn: Could not alloc driver-struct\n"); printk(KERN_WARNING "register_isdn: Could not alloc driver-struct\n");
return 0; return 0;
} }
memset((char *) d, 0, sizeof(isdn_driver_t));
d->maxbufsize = i->maxbufsize; d->maxbufsize = i->maxbufsize;
d->pktcount = 0; d->pktcount = 0;
......
...@@ -2542,17 +2542,15 @@ isdn_net_new(char *name, struct net_device *master) ...@@ -2542,17 +2542,15 @@ isdn_net_new(char *name, struct net_device *master)
printk(KERN_WARNING "isdn_net: interface %s already exists\n", name); printk(KERN_WARNING "isdn_net: interface %s already exists\n", name);
return NULL; return NULL;
} }
if (!(netdev = (isdn_net_dev *) kmalloc(sizeof(isdn_net_dev), GFP_KERNEL))) { if (!(netdev = kzalloc(sizeof(isdn_net_dev), GFP_KERNEL))) {
printk(KERN_WARNING "isdn_net: Could not allocate net-device\n"); printk(KERN_WARNING "isdn_net: Could not allocate net-device\n");
return NULL; return NULL;
} }
memset(netdev, 0, sizeof(isdn_net_dev)); if (!(netdev->local = kzalloc(sizeof(isdn_net_local), GFP_KERNEL))) {
if (!(netdev->local = (isdn_net_local *) kmalloc(sizeof(isdn_net_local), GFP_KERNEL))) {
printk(KERN_WARNING "isdn_net: Could not allocate device locals\n"); printk(KERN_WARNING "isdn_net: Could not allocate device locals\n");
kfree(netdev); kfree(netdev);
return NULL; return NULL;
} }
memset(netdev->local, 0, sizeof(isdn_net_local));
if (name == NULL) if (name == NULL)
strcpy(netdev->local->name, " "); strcpy(netdev->local->name, " ");
else else
......
...@@ -876,14 +876,12 @@ isdn_ppp_init(void) ...@@ -876,14 +876,12 @@ isdn_ppp_init(void)
#endif /* CONFIG_ISDN_MPP */ #endif /* CONFIG_ISDN_MPP */
for (i = 0; i < ISDN_MAX_CHANNELS; i++) { for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
if (!(ippp_table[i] = (struct ippp_struct *) if (!(ippp_table[i] = kzalloc(sizeof(struct ippp_struct), GFP_KERNEL))) {
kmalloc(sizeof(struct ippp_struct), GFP_KERNEL))) {
printk(KERN_WARNING "isdn_ppp_init: Could not alloc ippp_table\n"); printk(KERN_WARNING "isdn_ppp_init: Could not alloc ippp_table\n");
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
kfree(ippp_table[j]); kfree(ippp_table[j]);
return -1; return -1;
} }
memset((char *) ippp_table[i], 0, sizeof(struct ippp_struct));
spin_lock_init(&ippp_table[i]->buflock); spin_lock_init(&ippp_table[i]->buflock);
ippp_table[i]->state = 0; ippp_table[i]->state = 0;
ippp_table[i]->first = ippp_table[i]->rq + NUM_RCV_BUFFS - 1; ippp_table[i]->first = ippp_table[i]->rq + NUM_RCV_BUFFS - 1;
...@@ -1529,10 +1527,8 @@ static int isdn_ppp_mp_bundle_array_init(void) ...@@ -1529,10 +1527,8 @@ static int isdn_ppp_mp_bundle_array_init(void)
{ {
int i; int i;
int sz = ISDN_MAX_CHANNELS*sizeof(ippp_bundle); int sz = ISDN_MAX_CHANNELS*sizeof(ippp_bundle);
if( (isdn_ppp_bundle_arr = (ippp_bundle*)kmalloc(sz, if( (isdn_ppp_bundle_arr = kzalloc(sz, GFP_KERNEL)) == NULL )
GFP_KERNEL)) == NULL )
return -ENOMEM; return -ENOMEM;
memset(isdn_ppp_bundle_arr, 0, sz);
for( i = 0; i < ISDN_MAX_CHANNELS; i++ ) for( i = 0; i < ISDN_MAX_CHANNELS; i++ )
spin_lock_init(&isdn_ppp_bundle_arr[i].lock); spin_lock_init(&isdn_ppp_bundle_arr[i].lock);
return 0; return 0;
...@@ -2246,13 +2242,12 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto, ...@@ -2246,13 +2242,12 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto,
static struct ippp_ccp_reset *isdn_ppp_ccp_reset_alloc(struct ippp_struct *is) static struct ippp_ccp_reset *isdn_ppp_ccp_reset_alloc(struct ippp_struct *is)
{ {
struct ippp_ccp_reset *r; struct ippp_ccp_reset *r;
r = kmalloc(sizeof(struct ippp_ccp_reset), GFP_KERNEL); r = kzalloc(sizeof(struct ippp_ccp_reset), GFP_KERNEL);
if(!r) { if(!r) {
printk(KERN_ERR "ippp_ccp: failed to allocate reset data" printk(KERN_ERR "ippp_ccp: failed to allocate reset data"
" structure - no mem\n"); " structure - no mem\n");
return NULL; return NULL;
} }
memset(r, 0, sizeof(struct ippp_ccp_reset));
printk(KERN_DEBUG "ippp_ccp: allocated reset data structure %p\n", r); printk(KERN_DEBUG "ippp_ccp: allocated reset data structure %p\n", r);
is->reset = r; is->reset = r;
return r; return r;
...@@ -2338,10 +2333,9 @@ static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_s ...@@ -2338,10 +2333,9 @@ static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_s
id); id);
return NULL; return NULL;
} else { } else {
rs = kmalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL); rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL);
if(!rs) if(!rs)
return NULL; return NULL;
memset(rs, 0, sizeof(struct ippp_ccp_reset_state));
rs->state = CCPResetIdle; rs->state = CCPResetIdle;
rs->is = is; rs->is = is;
rs->id = id; rs->id = id;
......
...@@ -92,9 +92,8 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize) ...@@ -92,9 +92,8 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
int i; int i;
isdn_v110_stream *v; isdn_v110_stream *v;
if ((v = kmalloc(sizeof(isdn_v110_stream), GFP_ATOMIC)) == NULL) if ((v = kzalloc(sizeof(isdn_v110_stream), GFP_ATOMIC)) == NULL)
return NULL; return NULL;
memset(v, 0, sizeof(isdn_v110_stream));
v->key = key; v->key = key;
v->nbits = 0; v->nbits = 0;
for (i = 0; key & (1 << i); i++) for (i = 0; key & (1 << i); i++)
......
...@@ -1519,12 +1519,11 @@ icn_initcard(int port, char *id) ...@@ -1519,12 +1519,11 @@ icn_initcard(int port, char *id)
icn_card *card; icn_card *card;
int i; int i;
if (!(card = (icn_card *) kmalloc(sizeof(icn_card), GFP_KERNEL))) { if (!(card = kzalloc(sizeof(icn_card), GFP_KERNEL))) {
printk(KERN_WARNING printk(KERN_WARNING
"icn: (%s) Could not allocate card-struct.\n", id); "icn: (%s) Could not allocate card-struct.\n", id);
return (icn_card *) 0; return (icn_card *) 0;
} }
memset((char *) card, 0, sizeof(icn_card));
spin_lock_init(&card->lock); spin_lock_init(&card->lock);
card->port = port; card->port = port;
card->interface.owner = THIS_MODULE; card->interface.owner = THIS_MODULE;
......
...@@ -1430,12 +1430,11 @@ isdnloop_initcard(char *id) ...@@ -1430,12 +1430,11 @@ isdnloop_initcard(char *id)
isdnloop_card *card; isdnloop_card *card;
int i; int i;
if (!(card = (isdnloop_card *) kmalloc(sizeof(isdnloop_card), GFP_KERNEL))) { if (!(card = kzalloc(sizeof(isdnloop_card), GFP_KERNEL))) {
printk(KERN_WARNING printk(KERN_WARNING
"isdnloop: (%s) Could not allocate card-struct.\n", id); "isdnloop: (%s) Could not allocate card-struct.\n", id);
return (isdnloop_card *) 0; return (isdnloop_card *) 0;
} }
memset((char *) card, 0, sizeof(isdnloop_card));
card->interface.owner = THIS_MODULE; card->interface.owner = THIS_MODULE;
card->interface.channels = ISDNLOOP_BCH; card->interface.channels = ISDNLOOP_BCH;
card->interface.hl_hdrlen = 1; /* scratch area for storing ack flag*/ card->interface.hl_hdrlen = 1; /* scratch area for storing ack flag*/
......
...@@ -73,14 +73,13 @@ int pcbit_init_dev(int board, int mem_base, int irq) ...@@ -73,14 +73,13 @@ int pcbit_init_dev(int board, int mem_base, int irq)
struct pcbit_dev *dev; struct pcbit_dev *dev;
isdn_if *dev_if; isdn_if *dev_if;
if ((dev=kmalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL) if ((dev=kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL)
{ {
printk("pcbit_init: couldn't malloc pcbit_dev struct\n"); printk("pcbit_init: couldn't malloc pcbit_dev struct\n");
return -ENOMEM; return -ENOMEM;
} }
dev_pcbit[board] = dev; dev_pcbit[board] = dev;
memset(dev, 0, sizeof(struct pcbit_dev));
init_waitqueue_head(&dev->set_running_wq); init_waitqueue_head(&dev->set_running_wq);
spin_lock_init(&dev->lock); spin_lock_init(&dev->lock);
...@@ -104,7 +103,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) ...@@ -104,7 +103,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
return -EACCES; return -EACCES;
} }
dev->b1 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL); dev->b1 = kzalloc(sizeof(struct pcbit_chan), GFP_KERNEL);
if (!dev->b1) { if (!dev->b1) {
printk("pcbit_init: couldn't malloc pcbit_chan struct\n"); printk("pcbit_init: couldn't malloc pcbit_chan struct\n");
iounmap(dev->sh_mem); iounmap(dev->sh_mem);
...@@ -113,7 +112,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) ...@@ -113,7 +112,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
return -ENOMEM; return -ENOMEM;
} }
dev->b2 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL); dev->b2 = kzalloc(sizeof(struct pcbit_chan), GFP_KERNEL);
if (!dev->b2) { if (!dev->b2) {
printk("pcbit_init: couldn't malloc pcbit_chan struct\n"); printk("pcbit_init: couldn't malloc pcbit_chan struct\n");
kfree(dev->b1); kfree(dev->b1);
...@@ -123,8 +122,6 @@ int pcbit_init_dev(int board, int mem_base, int irq) ...@@ -123,8 +122,6 @@ int pcbit_init_dev(int board, int mem_base, int irq)
return -ENOMEM; return -ENOMEM;
} }
memset(dev->b1, 0, sizeof(struct pcbit_chan));
memset(dev->b2, 0, sizeof(struct pcbit_chan));
dev->b2->id = 1; dev->b2->id = 1;
INIT_WORK(&dev->qdelivery, pcbit_deliver); INIT_WORK(&dev->qdelivery, pcbit_deliver);
......
...@@ -369,13 +369,12 @@ pcbit_receive(struct pcbit_dev *dev) ...@@ -369,13 +369,12 @@ pcbit_receive(struct pcbit_dev *dev)
kfree(dev->read_frame); kfree(dev->read_frame);
dev->read_frame = NULL; dev->read_frame = NULL;
} }
frame = kmalloc(sizeof(struct frame_buf), GFP_ATOMIC); frame = kzalloc(sizeof(struct frame_buf), GFP_ATOMIC);
if (frame == NULL) { if (frame == NULL) {
printk(KERN_WARNING "kmalloc failed\n"); printk(KERN_WARNING "kmalloc failed\n");
return; return;
} }
memset(frame, 0, sizeof(struct frame_buf));
cpu = pcbit_readb(dev); cpu = pcbit_readb(dev);
proc = pcbit_readb(dev); proc = pcbit_readb(dev);
......
...@@ -271,14 +271,13 @@ static int __init sc_init(void) ...@@ -271,14 +271,13 @@ static int __init sc_init(void)
* Horray! We found a board, Make sure we can register * Horray! We found a board, Make sure we can register
* it with ISDN4Linux * it with ISDN4Linux
*/ */
interface = kmalloc(sizeof(isdn_if), GFP_KERNEL); interface = kzalloc(sizeof(isdn_if), GFP_KERNEL);
if (interface == NULL) { if (interface == NULL) {
/* /*
* Oops, can't malloc isdn_if * Oops, can't malloc isdn_if
*/ */
continue; continue;
} }
memset(interface, 0, sizeof(isdn_if));
interface->owner = THIS_MODULE; interface->owner = THIS_MODULE;
interface->hl_hdrlen = 0; interface->hl_hdrlen = 0;
...@@ -294,7 +293,7 @@ static int __init sc_init(void) ...@@ -294,7 +293,7 @@ static int __init sc_init(void)
/* /*
* Allocate the board structure * Allocate the board structure
*/ */
sc_adapter[cinst] = kmalloc(sizeof(board), GFP_KERNEL); sc_adapter[cinst] = kzalloc(sizeof(board), GFP_KERNEL);
if (sc_adapter[cinst] == NULL) { if (sc_adapter[cinst] == NULL) {
/* /*
* Oops, can't alloc memory for the board * Oops, can't alloc memory for the board
...@@ -302,7 +301,6 @@ static int __init sc_init(void) ...@@ -302,7 +301,6 @@ static int __init sc_init(void)
kfree(interface); kfree(interface);
continue; continue;
} }
memset(sc_adapter[cinst], 0, sizeof(board));
spin_lock_init(&sc_adapter[cinst]->lock); spin_lock_init(&sc_adapter[cinst]->lock);
if(!register_isdn(interface)) { if(!register_isdn(interface)) {
...@@ -326,7 +324,7 @@ static int __init sc_init(void) ...@@ -326,7 +324,7 @@ static int __init sc_init(void)
/* /*
* Allocate channels status structures * Allocate channels status structures
*/ */
sc_adapter[cinst]->channel = kmalloc(sizeof(bchan) * channels, GFP_KERNEL); sc_adapter[cinst]->channel = kzalloc(sizeof(bchan) * channels, GFP_KERNEL);
if (sc_adapter[cinst]->channel == NULL) { if (sc_adapter[cinst]->channel == NULL) {
/* /*
* Oops, can't alloc memory for the channels * Oops, can't alloc memory for the channels
...@@ -336,7 +334,6 @@ static int __init sc_init(void) ...@@ -336,7 +334,6 @@ static int __init sc_init(void)
kfree(sc_adapter[cinst]); kfree(sc_adapter[cinst]);
continue; continue;
} }
memset(sc_adapter[cinst]->channel, 0, sizeof(bchan) * channels);
/* /*
* Lock down the hardware resources * Lock down the hardware resources
......
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