win-pvdrivers

changeset 866:c3e9661e4f7e

Handle low memory conditions better
author James Harper <james.harper@bendigoit.com.au>
date Mon Feb 28 10:04:55 2011 +1100 (2011-02-28)
parents c755254d91c5
children fc034d9ccf1b
files xennet/xennet_rx.c
line diff
     1.1 --- a/xennet/xennet_rx.c	Sun Feb 27 21:32:27 2011 +1100
     1.2 +++ b/xennet/xennet_rx.c	Mon Feb 28 10:04:55 2011 +1100
     1.3 @@ -200,7 +200,12 @@ XenNet_MakePacket(struct xennet_info *xi
     1.4    }
     1.5    
     1.6    header_buf = NdisAllocateFromNPagedLookasideList(&xi->rx_lookaside_list);
     1.7 -  ASSERT(header_buf); // lazy
     1.8 +  if (!header_buf)
     1.9 +  {
    1.10 +    KdPrint((__DRIVER_NAME "     No free header buffers\n"));
    1.11 +    put_packet_on_freelist(xi, packet);
    1.12 +    return NULL;
    1.13 +  }
    1.14    header_va = (PUCHAR)(header_buf + 1);
    1.15    NdisZeroMemory(header_buf, sizeof(shared_buffer_t));
    1.16    NdisMoveMemory(header_va, pi->header, pi->header_length);
    1.17 @@ -212,7 +217,13 @@ XenNet_MakePacket(struct xennet_info *xi
    1.18    header_extra = pi->header_length - (MAX_ETH_HEADER_LENGTH + pi->ip4_header_length + pi->tcp_header_length);
    1.19    ASSERT(pi->header_length <= MAX_ETH_HEADER_LENGTH + MAX_LOOKAHEAD_LENGTH);
    1.20    NdisAllocateBuffer(&status, &out_buffer, xi->rx_buffer_pool, header_va, pi->header_length);
    1.21 -  ASSERT(status == STATUS_SUCCESS);
    1.22 +  if (status != STATUS_SUCCESS)
    1.23 +  {
    1.24 +    KdPrint((__DRIVER_NAME "     No free header buffers\n"));
    1.25 +    NdisFreeToNPagedLookasideList(&xi->rx_lookaside_list, header_buf);
    1.26 +    put_packet_on_freelist(xi, packet);
    1.27 +    return NULL;
    1.28 +  }
    1.29    NdisChainBufferAtBack(packet, out_buffer);
    1.30    *(shared_buffer_t **)&packet->MiniportReservedEx[0] = header_buf;
    1.31    header_buf->next = pi->curr_pb;