Re: [PATCH 2/2] net: Implement SO_PEERCGROUP

From: Vivek Goyal
Date: Thu Mar 13 2014 - 09:48:56 EST


On Wed, Mar 12, 2014 at 01:58:57PM -0700, Cong Wang wrote:
> On Wed, Mar 12, 2014 at 1:46 PM, Vivek Goyal <vgoyal@xxxxxxxxxx> wrote:
> > @@ -1098,6 +1135,16 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
> > if (newsk == NULL)
> > goto out;
> >
> > + err = init_peercgroup(newsk);
> > + if (err)
> > + goto out;
> > +
> > + err = alloc_cgroup_path(sk);
> > + if (err)
> > + goto out;
> > +
> > + err = -ENOMEM;
> > +
>
> Don't we need to free the cgroup_path on error path
> in this function?

Previous allocated cgroup_path is now in newsk->cgroup_path and I was
relying on __sk_free() freeing that memory if error happens.

unix_release_sock(sk)
sock_put()
sk_free()
__sk_free()
kfree(sk->cgroup_path)

Do you see a problem with that?

Thanks
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/