Skip to contentSkip to conversation

sch_atm.c-kzalloc

PATCH In review [email protected] 4 participants 6 messages Apr 16, 2007 – Apr 17, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sch_atm.c-kzalloc

Replacing kmalloc/memset combination with kzalloc.

---

net/sched/sch_atm.c +1 -2
index afb3bbd..4ef23d2 100644
@@ -308,13 +308,12 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
 		}
 	}
 	DPRINTK("atm_tc_change: new id %x\n",classid);
-	flow = kmalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
+	flow = kzalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
 	DPRINTK("atm_tc_change: flow %p\n",flow);
 	if (!flow) {
 		error = -ENOBUFS;
 		goto err_out;
 	}
-	memset(flow,0,sizeof(*flow));
 	flow->filter_list = NULL;
 	if (!(flow->q = qdisc_create_dflt(sch->dev,&pfifo_qdisc_ops,classid)))
 		flow->q = &noop_qdisc;
Signature · 4 lines
Regards,  
Vignesh Babu BM  
_____________________________________________________________  
"Why is it that every time I'm with you, makes me believe in magic?"

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#1 lore raw
Quoted 7 lines · On 4/16/07, [email protected] <[email protected]> wrote:

Replacing kmalloc/memset combination with kzalloc.

net/sched/sch_atm.c +0 -0
@@ -308,13 +308,12 @@ static int atm_tc_change(struct Qdisc *sch, u32
 classid, u32 parent,
 		}

net/sched/sch_atm.c static int atm_tc_change(struct Qdisc *sch, u32 · line 318

Quoted 10 lines
net/sched/sch_atm.c +1 -2
 	}
 	DPRINTK("atm_tc_change: new id %x\n",classid);
-	flow = kmalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
+	flow = kzalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
 	DPRINTK("atm_tc_change: flow %p\n",flow);
 	if (!flow) {
 		error = -ENOBUFS;
 		goto err_out;
 	}
-	memset(flow,0,sizeof(*flow));

A change which change runtime behaviour.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#2 lore raw
In reply to [email protected]

2007/4/16, Alexey Dobriyan <[email protected]>:

Quoted 12 lines · On 4/16/07, [email protected] <[email protected]> wrote:
Quoted 11 lines

Replacing kmalloc/memset combination with kzalloc.

net/sched/sch_atm.c +1 -1
@@ -308,13 +308,12 @@ static int atm_tc_change(struct Qdisc *sch, u32
 classid, u32 parent,
              }
      }
      DPRINTK("atm_tc_change: new id %x\n",classid);
-     flow = kmalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
+     flow = kzalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
Quoted 8 lines

net/sched/sch_atm.c static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, · line 317

Quoted 6 lines
net/sched/sch_atm.c +0 -1
      DPRINTK("atm_tc_change: flow %p\n",flow);
      if (!flow) {
              error = -ENOBUFS;
              goto err_out;
      }
-     memset(flow,0,sizeof(*flow));

A change which change runtime behaviour.

similar change happened in cfi_probe.c patch, but I don't think it's harmful...
_______________________________________________
Kernel-janitors mailing list [email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#3 lore raw
In reply to [email protected]

On 4/16/07, Marcin Åšlusarz <[email protected]> wrote:> 2007/4/16, Alexey Dobriyan <[email protected]>:> > On 4/16/07, [email protected] <[email protected]> wrote:> > > Replacing kmalloc/memset combination with kzalloc.> >> > > --- a/net/sched/sch_atm.c> > > +++ b/net/sched/sch_atm.c> > > @@ -308,13 +308,12 @@ static int atm_tc_change(struct Qdisc *sch, u32> > > classid, u32 parent,> > > }> > > }> > > DPRINTK("atm_tc_change: new id %x\n",classid);> > > - flow = kmalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);> > > + flow = kzalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
== Newbie Question ==What's the difference between the two kmalloc and the kzalloc calls? -- It's not much, but it's what I call 127.0.0.1
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#4 lore raw
In reply to [email protected]

kzalloc performs a kmalloc and if the allocation is successful it continues to perform a memset 0.

Quoted 7 lines · Chris Miller

On 4/16/07, Marcin Ślusarz <[email protected]> wrote:> 2007/4/16, Alexey Dobriyan <[email protected]>:> > On 4/16/07, [email protected] <[email protected]> wrote:> > > Replacing kmalloc/memset combination with kzalloc.> >> > > --- a/net/sched/sch_atm.c> > > +++ b/net/sched/sch_atm.c> > > @@ -308,13 +308,12 @@ static int atm_tc_change(struct Qdisc *sch, u32> > > classid, u32 parent,> > > }> > > }> > > DPRINTK("atm_tc_change: new id %x\n",classid);> > > - flow = kmalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);> > > + flow = kzalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
=== Newbie Question ===What's the difference between the two kmalloc and the kzalloc calls? -- It's not much, but it's what I call 127.0.0.1
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

Signature · 4 lines
Regards,  
Vignesh Babu BM  
_____________________________________________________________  
"Why is it that every time I'm with you, makes me believe in magic?"

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors