Skip to content

Commit beee1fb

Browse files
sstabelliniBoris Ostrovsky
authored andcommitted
pvcalls-front: properly allocate sk
Don't use kzalloc: it ends up leaving sk->sk_prot not properly initialized. Use sk_alloc instead and define our own trivial struct proto. Signed-off-by: Stefano Stabellini <stefanos@xilinx.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
1 parent 96283f9 commit beee1fb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/xen/pvcalls-front.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#define PVCALLS_NR_RSP_PER_RING __CONST_RING_SIZE(xen_pvcalls, XEN_PAGE_SIZE)
3232
#define PVCALLS_FRONT_MAX_SPIN 5000
3333

34+
static struct proto pvcalls_proto = {
35+
.name = "PVCalls",
36+
.owner = THIS_MODULE,
37+
.obj_size = sizeof(struct sock),
38+
};
39+
3440
struct pvcalls_bedata {
3541
struct xen_pvcalls_front_ring ring;
3642
grant_ref_t ref;
@@ -837,7 +843,7 @@ int pvcalls_front_accept(struct socket *sock, struct socket *newsock, int flags)
837843

838844
received:
839845
map2->sock = newsock;
840-
newsock->sk = kzalloc(sizeof(*newsock->sk), GFP_KERNEL);
846+
newsock->sk = sk_alloc(sock_net(sock->sk), PF_INET, GFP_KERNEL, &pvcalls_proto, false);
841847
if (!newsock->sk) {
842848
bedata->rsp[req_id].req_id = PVCALLS_INVALID_ID;
843849
map->passive.inflight_req_id = PVCALLS_INVALID_ID;

0 commit comments

Comments
 (0)