sockets: fix incorrect malloc size

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
This commit is contained in:
Andrey Zhadchenko 2020-10-01 21:18:40 +03:00 committed by Andrei Vagin
parent 749eb33a92
commit 5c4cc46fdc

View file

@ -414,12 +414,15 @@ static int restore_socket_filter(int sk, SkOptsEntry *soe)
pr_info("Restoring socket filter\n");
sfp.len = soe->n_so_filter;
sfp.filter = xmalloc(soe->n_so_filter * sfp.len);
sfp.filter = xmalloc(sfp.len * sizeof(struct sock_filter));
if (!sfp.filter)
return -1;
decode_filter(soe->so_filter, sfp.filter, sfp.len);
ret = restore_opt(sk, SOL_SOCKET, SO_ATTACH_FILTER, &sfp);
if (ret)
pr_err("Can't restore filter\n");
xfree(sfp.filter);
return ret;