summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/gpxe/pkbuff.h4
-rw-r--r--src/net/pkbuff.c5
2 files changed, 6 insertions, 3 deletions
diff --git a/src/include/gpxe/pkbuff.h b/src/include/gpxe/pkbuff.h
index 646b540d..92244fd5 100644
--- a/src/include/gpxe/pkbuff.h
+++ b/src/include/gpxe/pkbuff.h
@@ -33,7 +33,7 @@ struct ll_protocol;
* This structure is used to represent a network packet within gPXE.
*/
struct pk_buff {
- /** Head of the buffer */
+ /** Start of the buffer */
void *head;
/** Start of data */
void *data;
@@ -87,7 +87,7 @@ static inline void * pkb_push ( struct pk_buff *pkb, size_t len ) {
*/
static inline void * pkb_pull ( struct pk_buff *pkb, size_t len ) {
pkb->data += len;
- assert ( pkb->data >= pkb->tail );
+ assert ( pkb->data <= pkb->tail );
return pkb->data;
}
diff --git a/src/net/pkbuff.c b/src/net/pkbuff.c
index c1a6b2f7..964fbf62 100644
--- a/src/net/pkbuff.c
+++ b/src/net/pkbuff.c
@@ -40,7 +40,7 @@ struct pk_buff * alloc_pkb ( size_t len ) {
void *data;
/* Align buffer length */
- len = ( len + __alignof__ ( *pkb ) - 1 ) & ~ __alignof__ ( *pkb );
+ len = ( len + __alignof__( *pkb ) - 1 ) & ~( __alignof__( *pkb ) - 1 );
/* Allocate memory for buffer plus descriptor */
data = malloc_dma ( len + sizeof ( *pkb ), PKBUFF_ALIGN );
@@ -60,6 +60,9 @@ struct pk_buff * alloc_pkb ( size_t len ) {
*/
void free_pkb ( struct pk_buff *pkb ) {
if ( pkb ) {
+ assert ( pkb->head <= pkb->data );
+ assert ( pkb->data <= pkb->tail );
+ assert ( pkb->tail <= pkb->end );
free_dma ( pkb->head,
( pkb->end - pkb->head ) + sizeof ( *pkb ) );
}