Skip to content

Commit 6b098a0

Browse files
committed
Merge branch 'liquidio-lowmem-fixes'
Rick Farrington says: ==================== liquidio: avoid vm low memory crashes This patchset addresses issues brought about by low memory conditions in a VM. These conditions were not seen when the driver was exercised normally. Rather, they were brought about through manual fault injection. They are being included in the interest of hardening the driver against unforeseen circumstances. 1. Fix GPF in octeon_init_droq(); zero the allocated block 'recv_buf_list'. This prevents a GPF trying to access an invalid 'recv_buf_list[i]' entry in octeon_droq_destroy_ring_buffers() if init didn't alloc all entries. 2. Don't dereference a NULL ptr in octeon_droq_destroy_ring_buffers(). 3. For defensive programming, zero the allocated block 'oct->droq' in octeon_setup_output_queues() and 'oct->instr_queue' in octeon_setup_instr_queues(). change log: V1 -> V2: 1. Corrected syntax in 'Subject' lines; no functional or code changes. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 741912c + 2c4aac7 commit 6b098a0

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎drivers/net/ethernet/cavium/liquidio/octeon_device.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,11 @@ int octeon_setup_instr_queues(struct octeon_device *oct)
876876

877877
oct->num_iqs = 0;
878878

879-
oct->instr_queue[0] = vmalloc_node(sizeof(*oct->instr_queue[0]),
879+
oct->instr_queue[0] = vzalloc_node(sizeof(*oct->instr_queue[0]),
880880
numa_node);
881881
if (!oct->instr_queue[0])
882882
oct->instr_queue[0] =
883-
vmalloc(sizeof(struct octeon_instr_queue));
883+
vzalloc(sizeof(struct octeon_instr_queue));
884884
if (!oct->instr_queue[0])
885885
return 1;
886886
memset(oct->instr_queue[0], 0, sizeof(struct octeon_instr_queue));
@@ -923,9 +923,9 @@ int octeon_setup_output_queues(struct octeon_device *oct)
923923
desc_size = CFG_GET_DEF_RX_BUF_SIZE(CHIP_CONF(oct, cn23xx_vf));
924924
}
925925
oct->num_oqs = 0;
926-
oct->droq[0] = vmalloc_node(sizeof(*oct->droq[0]), numa_node);
926+
oct->droq[0] = vzalloc_node(sizeof(*oct->droq[0]), numa_node);
927927
if (!oct->droq[0])
928-
oct->droq[0] = vmalloc(sizeof(*oct->droq[0]));
928+
oct->droq[0] = vzalloc(sizeof(*oct->droq[0]));
929929
if (!oct->droq[0])
930930
return 1;
931931

‎drivers/net/ethernet/cavium/liquidio/octeon_droq.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ octeon_droq_destroy_ring_buffers(struct octeon_device *oct,
145145

146146
for (i = 0; i < droq->max_count; i++) {
147147
pg_info = &droq->recv_buf_list[i].pg_info;
148+
if (!pg_info)
149+
continue;
148150

149151
if (pg_info->dma)
150152
lio_unmap_ring(oct->pci_dev,
@@ -275,12 +277,12 @@ int octeon_init_droq(struct octeon_device *oct,
275277
droq->max_count);
276278

277279
droq->recv_buf_list = (struct octeon_recv_buffer *)
278-
vmalloc_node(droq->max_count *
280+
vzalloc_node(droq->max_count *
279281
OCT_DROQ_RECVBUF_SIZE,
280282
numa_node);
281283
if (!droq->recv_buf_list)
282284
droq->recv_buf_list = (struct octeon_recv_buffer *)
283-
vmalloc(droq->max_count *
285+
vzalloc(droq->max_count *
284286
OCT_DROQ_RECVBUF_SIZE);
285287
if (!droq->recv_buf_list) {
286288
dev_err(&oct->pci_dev->dev, "Output queue recv buf list alloc failed\n");

0 commit comments

Comments
 (0)