Showing error 797

User: Jiri Slaby
Error type: Memory Leak
Error type description: There the code omits to free some allocated memory
File location: net/sched/act_police.c
Line in file: 171
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:26:27 UTC


Source:

141                return -EINVAL;
142
143        err = nla_parse_nested(tb, TCA_POLICE_MAX, nla, police_policy);
144        if (err < 0)
145                return err;
146
147        if (tb[TCA_POLICE_TBF] == NULL)
148                return -EINVAL;
149        size = nla_len(tb[TCA_POLICE_TBF]);
150        if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
151                return -EINVAL;
152        parm = nla_data(tb[TCA_POLICE_TBF]);
153
154        if (parm->index) {
155                struct tcf_common *pc;
156
157                pc = tcf_hash_lookup(parm->index, &police_hash_info);
158                if (pc != NULL) {
159                        a->priv = pc;
160                        police = to_police(pc);
161                        if (bind) {
162                                police->tcf_bindcnt += 1;
163                                police->tcf_refcnt += 1;
164                        }
165                        if (ovr)
166                                goto override;
167                        return ret;
168                }
169        }
170
171        police = kzalloc(sizeof(*police), GFP_KERNEL);
172        if (police == NULL)
173                return -ENOMEM;
174        ret = ACT_P_CREATED;
175        police->tcf_refcnt = 1;
176        spin_lock_init(&police->tcf_lock);
177        if (bind)
178                police->tcf_bindcnt = 1;
179override:
180        if (parm->rate.rate) {
181                err = -ENOMEM;
Show full sources