[PATCH] Drivers: hv : vmbus: Adding NULL pointer check
From: cgel . zte
Date: Thu Oct 28 2021 - 06:41:48 EST
From: Lv Ruyi <lv.ruyi@xxxxxxxxxx>
This patch fixes the following Coccinelle warning:
drivers/hv/ring_buffer.c:223: alloc with no test
Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
Signed-off-by: Lv Ruyi <lv.ruyi@xxxxxxxxxx>
---
drivers/hv/ring_buffer.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 931802ae985c..4ef5c3771079 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -223,6 +223,8 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
pages_wraparound = kcalloc(page_cnt * 2 - 1,
sizeof(struct page *),
GFP_KERNEL);
+ if (!pages_wraparound)
+ return -ENOMEM;
pages_wraparound[0] = pages;
for (i = 0; i < 2 * (page_cnt - 1); i++)
--
2.25.1