Commit 5421ae01 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

scm: fix scm_fp_list->list initialization made in wrong place

This is the next page of the scm recursion story (the commit 
f8d570a4 net: Fix recursive descent in __scm_destroy()).

In function scm_fp_dup(), the INIT_LIST_HEAD(&fpl->list) of newly
created fpl is done *before* the subsequent memcpy from the old 
structure and thus the freshly initialized list is overwritten.

But that's OK, since this initialization is not required at all,
since the fpl->list is list_add-ed at the destruction time in any
case (and is unused in other code), so I propose to drop both
initializations, rather than moving it after the memcpy.

Please, correct me if I miss something significant.
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d8c3e23d
...@@ -75,7 +75,6 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp) ...@@ -75,7 +75,6 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
if (!fpl) if (!fpl)
return -ENOMEM; return -ENOMEM;
*fplp = fpl; *fplp = fpl;
INIT_LIST_HEAD(&fpl->list);
fpl->count = 0; fpl->count = 0;
} }
fpp = &fpl->fp[fpl->count]; fpp = &fpl->fp[fpl->count];
...@@ -301,7 +300,6 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl) ...@@ -301,7 +300,6 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl)
new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL); new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL);
if (new_fpl) { if (new_fpl) {
INIT_LIST_HEAD(&new_fpl->list);
for (i=fpl->count-1; i>=0; i--) for (i=fpl->count-1; i>=0; i--)
get_file(fpl->fp[i]); get_file(fpl->fp[i]);
memcpy(new_fpl, fpl, sizeof(*fpl)); memcpy(new_fpl, fpl, sizeof(*fpl));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment