Re: [PATCH linux 2/2] net sched actions: fix refcount decrement on error
From: Roman Mashak
Date: Thu Apr 13 2017 - 09:40:03 EST
Wolfgang Bumiller <w.bumiller@xxxxxxxxxxx> writes:
> If memory allocation for nla_memdup_cookie() fails
> module_put has to be guarded by the same condition as it was
> before the TCA_ACT_COOKIE has been added as stated in the
> comment afterwards:
>
What if a new entry has been created, and a_o->init returns
ACT_P_CREATED, but cookie allocation fails, do we not remove module
reference count?
[...]
> if (cklen > TC_COOKIE_MAX_SIZE) {
> - err = -EINVAL;
> tcf_hash_release(a, bind);
> - goto err_mod;
> + if (err != ACT_P_CREATED)
> + module_put(a_o->owner);
> + err = -EINVAL;
> + goto err_out;
> }
>
> if (nla_memdup_cookie(a, tb) < 0) {
> - err = -ENOMEM;
> tcf_hash_release(a, bind);
> - goto err_mod;
> + if (err != ACT_P_CREATED)
> + module_put(a_o->owner);
> + err = -ENOMEM;
> + goto err_out;
> }
> }