[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1547436023-5797-1-git-send-email-wen.yang99@zte.com.cn>
Date: Mon, 14 Jan 2019 11:20:23 +0800
From: Wen Yang <wen.yang99@....com.cn>
To: boris.ostrovsky@...cle.com
Cc: jgross@...e.com, sstabellini@...nel.org,
xen-devel@...ts.xenproject.org, linux-kernel@...r.kernel.org,
xue.zhihong@....com.cn, wang.yi59@....com.cn,
Wen Yang <wen.yang99@....com.cn>,
Dan Carpenter <dan.carpenter@...cle.com>
Subject: [PATCH] pvcalls-front: fix potential null dereference
static checker warning:
drivers/xen/pvcalls-front.c:373 alloc_active_ring()
error: we previously assumed 'map->active.ring' could be null
(see line 357)
drivers/xen/pvcalls-front.c
351 static int alloc_active_ring(struct sock_mapping *map)
352 {
353 void *bytes;
354
355 map->active.ring = (struct pvcalls_data_intf *)
356 get_zeroed_page(GFP_KERNEL);
357 if (!map->active.ring)
^^^^^^^^^^^^^^^^^
Check
358 goto out;
359
360 map->active.ring->ring_order = PVCALLS_RING_ORDER;
361 bytes = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
362 PVCALLS_RING_ORDER);
363 if (!bytes)
364 goto out;
365
366 map->active.data.in = bytes;
367 map->active.data.out = bytes +
368 XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER);
369
370 return 0;
371
372 out:
--> 373 free_active_ring(map);
^^^
Replace map->active.ring->ring_order with PVCALLS_RING_ORDER
to avoid potential null dereference.
Fixes: 9f51c05dc41a ("pvcalls-front: Avoid get_free_pages(GFP_KERNEL)
under spinlock")
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Wen Yang <wen.yang99@....com.cn>
CC: Boris Ostrovsky <boris.ostrovsky@...cle.com>
CC: Juergen Gross <jgross@...e.com>
CC: Stefano Stabellini <sstabellini@...nel.org>
CC: Dan Carpenter <dan.carpenter@...cle.com>
CC: xen-devel@...ts.xenproject.org
CC: linux-kernel@...r.kernel.org
---
drivers/xen/pvcalls-front.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
index 307861f..e56f9a3 100644
--- a/drivers/xen/pvcalls-front.c
+++ b/drivers/xen/pvcalls-front.c
@@ -344,7 +344,7 @@ int pvcalls_front_socket(struct socket *sock)
static void free_active_ring(struct sock_mapping *map)
{
free_pages((unsigned long)map->active.data.in,
- map->active.ring->ring_order);
+ PVCALLS_RING_ORDER);
free_page((unsigned long)map->active.ring);
}
--
2.9.5
Powered by blists - more mailing lists