enic: cleanup vic_provinfo_alloc()
Subsystems (3)
PATCH 1/1 enic: cleanup vic_provinfo_alloc()
If oui were a null variable then vic_provinfo_alloc() would leak memory. But this function is only called from one place and oui is not null so I removed the check.
I also moved the memory allocation down a line so it was easier to spot. (No one ever reads variable declarations).
drivers/net/enic/vnic_vic.c +3 -2
@@ -25,9 +25,10 @@struct vic_provinfo *vic_provinfo_alloc (gfp_t flags,u8 *oui,u8 type) { -struct vic_provinfo *vp =kzalloc (VIC_PROVINFO_MAX_DATA , flags); +struct vic_provinfo *vp; -if (!vp || !oui) + vp =kzalloc (VIC_PROVINFO_MAX_DATA , flags); +if (!vp)return NULL ;memcpy (vp->oui, oui,sizeof (vp->oui));
Quoted 17 lines · Dan Carpenter
If oui were a null variable then
vic_provinfo_alloc()would leak memory. But this function is only called from one place and oui is not null so I removed the check.I also moved the memory allocation down a line so it was easier to spot. (No one ever reads variable declarations).
Signed-off-by Dan Carpenter <[email protected]>drivers/net/enic/vnic_vic.c +0
-0@@ -25,9 +25,10 @@struct vic_provinfo *vic_provinfo_alloc (gfp_t flags,u8 *oui,u8 type) {
drivers/net/enic/vnic_vic.c
Quoted 10 lines
drivers/net/enic/vnic_vic.c +3
-3-struct vic_provinfo *vp =kzalloc (VIC_PROVINFO_MAX_DATA , flags); +struct vic_provinfo *vp; -if (!vp || !oui) + vp =kzalloc (VIC_PROVINFO_MAX_DATA , flags); +if (!vp)return NULL ;memcpy (vp->oui, oui,sizeof (vp->oui)); --
This looks like memdup() ?
re,
wh
Quoted 10 lines · walter harms
drivers/net/enic/vnic_vic.c
Quoted 6 lines
drivers/net/enic/vnic_vic.c +2
-1+ vp =kzalloc (VIC_PROVINFO_MAX_DATA , flags); +if (!vp)return NULL ;memcpy (vp->oui, oui,sizeof (vp->oui)); --This looks like
memdup()?
No. VIC_PROVINFO_MAX_DATA is larger than sizeof(vp->oui).
regards,
dan carpenter
Quoted 2 lines
re,
wh
Quoted 8 lines · Dan Carpenter
If oui were a null variable then
vic_provinfo_alloc()would leak memory. But this function is only called from one place and oui is not null so I removed the check.I also moved the memory allocation down a line so it was easier to spot. (No one ever reads variable declarations).
Signed-off-by Dan Carpenter <[email protected]>
We'll pick this one up and resubmit with the next enic patch bomb. Thanks Dan.
-scott
From: Dan Carpenter <[email protected]>
Date: Thu, 10 Jun 2010 09:59:03 +0200
Quoted 8 lines
If oui were a null variable then
vic_provinfo_alloc()would leak memory. But this function is only called from one place and oui is not null so I removed the check.I also moved the memory allocation down a line so it was easier to spot. (No one ever reads variable declarations).
Signed-off-by Dan Carpenter <[email protected]>
Applied to net-next-2.6, thanks.