Commit beee1fbe authored by Stefano Stabellini's avatar Stefano Stabellini Committed by Boris Ostrovsky
Browse files

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: default avatarStefano Stabellini <stefanos@xilinx.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
parent 96283f9a
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -31,6 +31,12 @@
#define PVCALLS_NR_RSP_PER_RING __CONST_RING_SIZE(xen_pvcalls, XEN_PAGE_SIZE)
#define PVCALLS_NR_RSP_PER_RING __CONST_RING_SIZE(xen_pvcalls, XEN_PAGE_SIZE)
#define PVCALLS_FRONT_MAX_SPIN 5000
#define PVCALLS_FRONT_MAX_SPIN 5000


static struct proto pvcalls_proto = {
	.name	= "PVCalls",
	.owner	= THIS_MODULE,
	.obj_size = sizeof(struct sock),
};

struct pvcalls_bedata {
struct pvcalls_bedata {
	struct xen_pvcalls_front_ring ring;
	struct xen_pvcalls_front_ring ring;
	grant_ref_t ref;
	grant_ref_t ref;
@@ -837,7 +843,7 @@ int pvcalls_front_accept(struct socket *sock, struct socket *newsock, int flags)


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