245-ac4
Subsystems (10)
PATCH 1/1 245-ac4
Hi all,
This patch remove some NULL parameters tests in kfree-like functions and add this directly in function.
- dev_kfree_skb_irq == dev_kfree_skb == kfree_skb
- kfree already handle null parameters :
void kfree (const void *objp)
{
kmem_cache_t *c;
unsigned long flags;Quoted 2 lines
Quoted 2 lines
if (!objp) return;
local_irq_save(flags);
CHECK_PAGE(virt_to_page(objp));
c = GET_PAGE_CACHE(virt_to_page(objp));
__kmem_cache_free(c, (void*)objp);
local_irq_restore(flags);
}arch/i386/kernel/mtrr.c +1 -1
@@ -966,7 +966,7 @@/* Free resources associated with a struct mtrr_state */ static void __init finalize_mtrr_state (struct mtrr_state *state) { -if (state->var_ranges)kfree (state->var_ranges); +kfree (state->var_ranges); }/* End Function finalize_mtrr_state */
arch/ia64/kernel/efivars.c +2 -2
@@ -163,8 +163,8 @@efivar_entry_t *new_efivar =kmalloc (sizeof (efivar_entry_t),GFP_KERNEL );if (!short_name || !new_efivar) { -if (short_name)kfree (short_name); -if (new_efivar)kfree (new_efivar); +kfree (short_name); +kfree (new_efivar);return 1 ; }memset (short_name,0 , short_name_size+1 );
arch/sparc64/kernel/ioctl32.c +6 -5
@@ -1024,10 +1024,10 @@if (err) err = -EFAULT ; -out:if (cmap.red)kfree (cmap.red); -if (cmap.green)kfree (cmap.green); -if (cmap.blue)kfree (cmap.blue); -if (cmap.transp)kfree (cmap.transp); +out:kfree (cmap.red); +kfree (cmap.green); +kfree (cmap.blue); +kfree (cmap.transp);return err; }
@@ -1356,7 +1356,7 @@if (err) err = -EFAULT ; -out:if (karg)kfree (karg); +out:kfree (karg);return err; }
@@ -2222,6 +2222,7 @@static void put_lv_t (lv_t *l) { +if (!l)return ;if (l->lv_current_pe)vfree (l->lv_current_pe);if (l->lv_block_exception)vfree (l->lv_block_exception);kfree (l);
arch/um/fs/hostfs/hostfs_kern.c +1 -1
@@ -110,7 +110,7 @@void hostfs_delete_inode (struct inode *ino) { -if (ino->u.generic_ip)kfree (ino->u.generic_ip); +kfree (ino->u.generic_ip); ino->u.generic_ip =NULL ;clear_inode (ino); }
arch/um/kernel/process_kern.c +1 -1
@@ -584,7 +584,7 @@if (t ==NULL ) task = current;else task = t; -if (task->thread.altstack !=NULL )kfree (task->thread.altstack); +kfree (task->thread.altstack); n =PAGE_SIZE - (sp & ~PAGE_MASK ); stack =kmalloc (n,GFP_KERNEL );if (stack ==NULL )panic ("save_altstack : kmalloc failed" );
drivers/atm/ambassador.c +1 -0
@@ -458,6 +458,7 @@/********** free an skb (as per ATM device driver documentation) **********/ static inline void amb_kfree_skb (struct sk_buff * skb) { +if (!skb)return ;if (ATM_SKB (skb)->vcc->pop) {ATM_SKB (skb)->vcc->pop (ATM_SKB (skb)->vcc, skb); }else {
drivers/atm/eni.c +1 -1
@@ -487,7 +487,7 @@if (paddr)pci_unmap_single (eni_dev->pci_dev,paddr,skb->len,PCI_DMA_FROMDEVICE ); -if (skb)dev_kfree_skb_irq (skb); +dev_kfree_skb_irq (skb);return -1 ; }
drivers/atm/zatm.c +1 -1
@@ -1100,7 +1100,7 @@ zatm_dev->tx_bw += vcc->qos.txtp.min_pcr;dealloc_shaper (vcc->dev,zatm_vcc->shaper); } -if (zatm_vcc->ring)kfree (zatm_vcc->ring); +kfree (zatm_vcc->ring); }
drivers/fc4/fc.c +2 -2
@@ -559,8 +559,8 @@ l->logi =kmalloc (count *3 *sizeof (logi),GFP_KERNEL ); l->fcmds =kmalloc (count *sizeof (fcp_cmnd),GFP_KERNEL );if (!l->logi || !l->fcmds) { -if (l->logi)kfree (l->logi); -if (l->fcmds)kfree (l->fcmds); +kfree (l->logi); +kfree (l->fcmds);kfree (l);printk ("FC: Cannot allocate DMA memory for initialization\n" );return -ENOMEM ;
drivers/ieee1394/ohci1394.c +1 -1
@@ -1612,7 +1612,7 @@kfree ((*d)->prg_cpu);kfree ((*d)->prg_bus); } -if ((*d)->spb)kfree ((*d)->spb); +kfree ((*d)->spb);kfree (*d); *d =NULL ;
drivers/ieee1394/video1394.c +2 -2
@@ -277,13 +277,13 @@if ((*d)->ir_prg) {for (i=0 ;i<(*d)->num_desc;i++) -if ((*d)->ir_prg[i])kfree ((*d)->ir_prg[i]); +kfree ((*d)->ir_prg[i]);kfree ((*d)->ir_prg); }if ((*d)->it_prg) {for (i=0 ;i<(*d)->num_desc;i++) -if ((*d)->it_prg[i])kfree ((*d)->it_prg[i]); +kfree ((*d)->it_prg[i]);kfree ((*d)->it_prg); }
drivers/isdn/avmb1/capi.c +1 -1
@@ -262,7 +262,7 @@while (*pp) {if (*pp == mp) { *pp = (*pp)->next; -if (mp->ttyskb)kfree_skb (mp->ttyskb); +kfree_skb (mp->ttyskb); mp->ttyskb =0 ;while ((skb =skb_dequeue (&mp->recvqueue)) !=0 )kfree_skb (skb);
drivers/net/defxx.c +1 -1
@@ -3339,7 +3339,7 @@unregister_netdev (dev);release_region (dev->base_addr, pdev ?PFI_K_CSR_IO_LEN :PI_ESIC_K_CSR_IO_LEN ); -if (bp->kmalloced)kfree (bp->kmalloced); +kfree (bp->kmalloced);kfree (dev); }
drivers/net/strip.c +6 -6
@@ -945,9 +945,9 @@ strip_info->mtu = dev->mtu;return (1 ); } -if (r)kfree (r); -if (s)kfree (s); -if (t)kfree (t); +kfree (r); +kfree (s); +kfree (t);return (0 ); }
@@ -1020,9 +1020,9 @@printk (KERN_NOTICE "%s: strip MTU changed fom %d to %d.\n" , strip_info->dev.name, old_mtu, strip_info->mtu); -if (orbuff)kfree (orbuff); -if (osbuff)kfree (osbuff); -if (otbuff)kfree (otbuff); +kfree (orbuff); +kfree (osbuff); +kfree (otbuff); }static void strip_unlock (struct strip *strip_info)
drivers/net/wan/comx-hw-comx.c +2 -4
@@ -1079,9 +1079,7 @@ && hw->firmware->len < count + file->f_pos) {memcpy (tmp, hw->firmware->data, hw->firmware->len); } -if (hw->firmware->data) { -kfree (hw->firmware->data); - } +kfree (hw->firmware->data);copy_from_user (tmp + file->f_pos, buffer, count); hw->firmware->len = entry->size = file->f_pos + count; hw->firmware->data = tmp;
@@ -1367,7 +1365,7 @@struct comx_privdata *hw = ch->HW_privdata;if (hw->firmware) { -if (hw->firmware->data)kfree (hw->firmware->data); +kfree (hw->firmware->data);kfree (hw->firmware); }if (ch->twin) {struct comx_channel *twin_ch = ch->twin->priv;
drivers/net/wan/comx.c +1 -1
@@ -644,7 +644,7 @@unsigned long flags;save_flags (flags);cli (); -if (ch->debug_area)kfree (ch->debug_area); +kfree (ch->debug_area);if ((ch->debug_area =kmalloc (ch->debug_size = i,GFP_KERNEL )) ==NULL ) { ret = -ENOMEM ;
drivers/s390/char/tape.c +2 -2
@@ -766,8 +766,8 @@debug_int_event (tape_debug_area,6 ,temp->devinfo.irq);#endif /* TAPE_DEBUG */ free_irq (temp->devinfo.irq, &(temp->devstat)); -if (temp->discdata)kfree (temp->discdata); -if (temp->kernbuf)kfree (temp->kernbuf); +kfree (temp->discdata); +kfree (temp->kernbuf);if (temp->cqr)tape_free_request (temp->cqr);#ifdef CONFIG_DEVFS_FS for (frontend=first_frontend;frontend!=NULL ;frontend=frontend->next)
drivers/scsi/eata.c +1 -1
@@ -2059,7 +2059,7 @@ }for (i =0 ; i < sh[j]->can_queue; i++) -if ((&HD (j)->cp[i])->sglist)kfree ((&HD (j)->cp[i])->sglist); +kfree ((&HD (j)->cp[i])->sglist);free_irq (sh[j]->irq, &sha[j]);
drivers/scsi/ide-scsi.c +2 -2
@@ -790,8 +790,8 @@spin_lock_irq (&io_request_lock);return 0 ; abort: -if (pc)kfree (pc); -if (rq)kfree (rq); +kfree (pc); +kfree (rq); cmd->result =DID_ERROR <<16 ;done (cmd);return 0 ;
drivers/scsi/u14-34f.c +1 -1
@@ -1745,7 +1745,7 @@ }for (i =0 ; i < sh[j]->can_queue; i++) -if ((&HD (j)->cp[i])->sglist)kfree ((&HD (j)->cp[i])->sglist); +kfree ((&HD (j)->cp[i])->sglist);free_irq (sh[j]->irq, &sha[j]);
drivers/sound/maestro.c +1 -1
@@ -2349,7 +2349,7 @@ } rec_return_free: -if (combbuf)kfree (combbuf); +kfree (combbuf);return ret; }
drivers/usb/hid-core.c +1 -1
@@ -529,7 +529,7 @@ } } -if (device->rdesc)kfree (device->rdesc); +kfree (device->rdesc); }/*
fs/devfs/base.c +2 -2
@@ -1395,7 +1395,7 @@if (S_ISLNK (de->mode) ) { de->registered = FALSE; -if (de->u.symlink.linkname !=NULL )kfree (de->u.symlink.linkname); +kfree (de->u.symlink.linkname); de->u.symlink.linkname =NULL ;return ; }
@@ -1518,7 +1518,7 @@kfree (de);return -ENOMEM ; } -if (de->u.symlink.linkname !=NULL )kfree (de->u.symlink.linkname); +kfree (de->u.symlink.linkname); de->u.symlink.linkname = newname;memcpy (de->u.symlink.linkname, link, linklength); de->u.symlink.linkname[linklength] ='\0' ;
fs/hpfs/dnode.c +4 -4
@@ -236,12 +236,12 @@ go_up:if (namelen >=256 ) {hpfs_error (i->i_sb,"hpfs_add_to_dnode: namelen == %d" , namelen); -if (nd)kfree (nd); +kfree (nd);kfree (nname);return 1 ; }if (!(d =hpfs_map_dnode (i->i_sb, dno, &qbh))) { -if (nd)kfree (nd); +kfree (nd);kfree (nname);return 1 ; }
@@ -249,7 +249,7 @@if (i->i_sb->s_hpfs_chk)if (hpfs_stop_cycles (i->i_sb, dno, &c1, &c2,"hpfs_add_to_dnode" )) {hpfs_brelse4 (&qbh); -if (nd)kfree (nd); +kfree (nd);kfree (nname);return 1 ; }
@@ -262,7 +262,7 @@for_all_poss (i, hpfs_pos_subst,5 , t +1 );hpfs_mark_4buffers_dirty (&qbh);hpfs_brelse4 (&qbh); -if (nd)kfree (nd); +kfree (nd);kfree (nname);return 0 ; }
fs/hpfs/super.c +5 -5
@@ -74,7 +74,7 @@ }else if (s->s_flags &MS_RDONLY )printk ("; going on - but anything won't be destroyed because it's read-only\n" );else printk ("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n" ); }else printk ("\n" ); -if (buf)kfree (buf); +kfree (buf); s->s_hpfs_was_error =1 ; }
@@ -100,8 +100,8 @@void hpfs_put_super (struct super_block *s) { -if (s->s_hpfs_cp_table)kfree (s->s_hpfs_cp_table); -if (s->s_hpfs_bmp_dir)kfree (s->s_hpfs_bmp_dir); +kfree (s->s_hpfs_cp_table); +kfree (s->s_hpfs_bmp_dir);unmark_dirty (s); }
@@ -551,8 +551,8 @@ bail2:brelse (bh0); bail1: bail0: -if (s->s_hpfs_bmp_dir)kfree (s->s_hpfs_bmp_dir); -if (s->s_hpfs_cp_table)kfree (s->s_hpfs_cp_table); +kfree (s->s_hpfs_bmp_dir); +kfree (s->s_hpfs_cp_table);return NULL ; }
fs/isofs/rock.c +2 -2
@@ -60,7 +60,7 @@ }#define MAYBE_CONTINUE (LABEL ,DEV ) \ - {if (buffer) kfree(buffer); \ + { kfree(buffer); \ if (cont_extent){ \ int block, offset, offset1; \ struct buffer_head * pbh; \
@@ -213,7 +213,7 @@ retnamlen += rr->len -5 ;break ;case SIG ('R' ,'E' ): -if (buffer)kfree (buffer); +kfree (buffer);return -1 ;default :break ;
fs/jffs2/gc.c +1 -1
@@ -649,7 +649,7 @@ f->metadata =NULL ; } } -if (comprbuf)kfree (comprbuf); +kfree (comprbuf);kunmap (pg);/* XXX: Does the page get freed automatically? */
fs/ufs/super.c +3 -3
@@ -382,13 +382,13 @@return 1 ; failed: -if (base)kfree (base); +kfree (base);if (sb->u.ufs_sb.s_ucg) {for (i =0 ; i < uspi->s_ncg; i++)if (sb->u.ufs_sb.s_ucg[i])brelse (sb->u.ufs_sb.s_ucg[i]);kfree (sb->u.ufs_sb.s_ucg);for (i =0 ; i <UFS_MAX_GROUP_LOADED ; i++) -if (sb->u.ufs_sb.s_ucpi[i])kfree (sb->u.ufs_sb.s_ucpi[i]); +kfree (sb->u.ufs_sb.s_ucpi[i]); } UFSD(("EXIT (FAILED)\n"))return 0 ;
@@ -823,7 +823,7 @@ failed:if (ubh)ubh_brelse_uspi (uspi); -if (uspi)kfree (uspi); +kfree (uspi); UFSD(("EXIT (FAILED)\n"))return (NULL ); }
include/linux/skbuff.h +1 -0
@@ -286,6 +286,7 @@static inline void kfree_skb (struct sk_buff *skb) { +if (!skb)return ;if (atomic_read (&skb->users) ==1 ||atomic_dec_and_test (&skb->users))__kfree_skb (skb); }
net/ax25/af_ax25.c +1 -1
@@ -1207,7 +1207,7 @@ }if (sk->type ==SOCK_SEQPACKET &&ax25_find_cb (&sk->protinfo.ax25->source_addr, &fsa->fsa_ax25.sax25_call, digi, sk->protinfo.ax25->ax25_dev->dev) !=NULL ) { -if (digi !=NULL )kfree (digi); +kfree (digi);return -EADDRINUSE ;/* Already such a connection */ }
net/core/skbuff.c +1 -0
@@ -295,6 +295,7 @@*/ void kfree_skbmem (struct sk_buff *skb) { +if (!skb)return ;skb_release_data (skb);skb_head_to_pool (skb); }
--
_________________________ Carlos E Gorges ([email protected]) Tech informática LTDA Brazil _________________________
Mikulas Patocka
maintainerQuoted 15 lines
Hi all,
This patch remove some NULL parameters tests in kfree-like functions and add this directly in function.
-
dev_kfree_skb_irq==dev_kfree_skb==kfree_skb
- kfree already handle null parameters :
void kfree (const void *objp){ kmem_cache_t *c; unsigned long flags;Quoted 2 lines
Quoted 2 lines
if (!objp) return;
Quoted 6 lines
local_irq_save(flags);
CHECK_PAGE(virt_to_page(objp));
c = GET_PAGE_CACHE(virt_to_page(objp));
__kmem_cache_free(c, (void*)objp);
local_irq_restore(flags);
}This is bad. It will only slow thing down.
It will also hide allocation errors in the rest of the kernel. A bug that causes crash is much better than the one that doesn't.
Mikulas
Quoted 2 lines
This patch remove some NULL parameters tests in kfree-like functions an= d add this directly in function.
Please dont do this, it just makes it harder to follow the tests and the code logic