Index: uspace/srv/net/netif/dp8390/dp8390.c
===================================================================
--- uspace/srv/net/netif/dp8390/dp8390.c	(revision bfd7aacc7de086de3588ff054d013521d83f6108)
+++ uspace/srv/net/netif/dp8390/dp8390.c	(revision 1e2e0c1eeb07d0d3faf4a5b53314c73e3b0c1a2a)
@@ -350,5 +350,5 @@
 		tmp = pq_next( tmp );
 	}
-	if( ! pq_add( tmp, packet, 0, 0 )){
+	if( pq_add( & tmp, packet, 0, 0 ) != EOK ){
 		return EINVAL;
 	}
@@ -1006,5 +1006,4 @@
 	int last, count;
 	packet_t	packet;
-	packet_t	queue;
 
 //	if (!(dep->de_flags & DEF_READING))
@@ -1045,7 +1044,5 @@
 		return ELIMIT;
 	}else{
-		queue = pq_add( dep->received_queue, packet, 0, 0 );
-		if( queue ){
-			dep->received_queue = queue;
+		if( pq_add( & dep->received_queue, packet, 0, 0 ) == EOK ){
 			++ dep->received_count;
 		}else{
Index: uspace/srv/net/structures/packet/packet.c
===================================================================
--- uspace/srv/net/structures/packet/packet.c	(revision bfd7aacc7de086de3588ff054d013521d83f6108)
+++ uspace/srv/net/structures/packet/packet.c	(revision 1e2e0c1eeb07d0d3faf4a5b53314c73e3b0c1a2a)
@@ -184,11 +184,11 @@
 }
 
-packet_t pq_add( packet_t first, packet_t packet, size_t order, size_t metric ){
+int pq_add( packet_t * first, packet_t packet, size_t order, size_t metric ){
 	packet_t	item;
 
-	if( ! packet_is_valid( packet )) return NULL;
+	if(( ! first ) || ( ! packet_is_valid( packet ))) return EINVAL;
 	pq_set_order( packet, order, metric );
-	if( packet_is_valid( first )){
-		item = first;
+	if( packet_is_valid( * first )){
+		item = * first;
 		do{
 			if( item->order < order ){
@@ -198,5 +198,5 @@
 					item->next = packet->packet_id;
 					packet->previous = item->packet_id;
-					return first;
+					return EOK;
 				}
 			}else{
@@ -205,10 +205,15 @@
 				item->previous = packet->packet_id;
 				item = pm_find( packet->previous );
-				if( item ) item->next = packet->packet_id;
-				return item ? first : packet;
+				if( item ){
+					item->next = packet->packet_id;
+				}else{
+					* first = packet;
+				}
+				return EOK;
 			}
 		}while( packet_is_valid( item ));
 	}
-	return packet;
+	* first = packet;
+	return EOK;
 }
 
Index: uspace/srv/net/structures/packet/packet.h
===================================================================
--- uspace/srv/net/structures/packet/packet.h	(revision bfd7aacc7de086de3588ff054d013521d83f6108)
+++ uspace/srv/net/structures/packet/packet.h	(revision 1e2e0c1eeb07d0d3faf4a5b53314c73e3b0c1a2a)
@@ -86,12 +86,13 @@
  *  The queue is sorted in the ascending order.
  *  The packet is inserted right before the packets of the same order value.
- *  @param[in] first The first packet of the queue. May be NULL.
+ *  @param[in,out] first The first packet of the queue. Sets the first packet of the queue. The original first packet may be shifted by the new packet.
  *  @param[in] packet The packet to be added.
  *  @param[in] order The packet order value.
  *  @param[in] metric The metric value of the packet.
- *  @returns The first packet of the queue. The original first packet may be shifted by the new packet.
- *  @returns NULL if the packet is not valid.
+ *  @returns EOK on success.
+ *  @returns EINVAL if the first parameter is NULL.
+ *  @returns EINVAL if the packet is not valid.
  */
-packet_t	pq_add( packet_t first, packet_t packet, size_t order, size_t metric );
+int	pq_add( packet_t * first, packet_t packet, size_t order, size_t metric );
 
 /** Finds the packet with the given order.
Index: uspace/srv/net/structures/packet/packet_server.c
===================================================================
--- uspace/srv/net/structures/packet/packet_server.c	(revision bfd7aacc7de086de3588ff054d013521d83f6108)
+++ uspace/srv/net/structures/packet/packet_server.c	(revision 1e2e0c1eeb07d0d3faf4a5b53314c73e3b0c1a2a)
@@ -229,10 +229,11 @@
 void packet_release( packet_t packet ){
 	int index;
+	int result;
 
 	// remove debug dump
 //	printf( "packet %d released\n", packet->packet_id );
 	for( index = 0; ( index < FREE_QUEUES_COUNT - 1 ) && ( packet->length > ps_globals.sizes[ index ] ); ++ index );
-	ps_globals.free[ index ] = pq_add( ps_globals.free[ index ], packet, packet->length, packet->length );
-	assert( ps_globals.free[ index ] );
+	result = pq_add( & ps_globals.free[ index ], packet, packet->length, packet->length );
+	assert( result == EOK );
 }
 
Index: uspace/srv/net/tl/tcp/tcp.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp.c	(revision bfd7aacc7de086de3588ff054d013521d83f6108)
+++ uspace/srv/net/tl/tcp/tcp.c	(revision 1e2e0c1eeb07d0d3faf4a5b53314c73e3b0c1a2a)
@@ -613,11 +613,9 @@
 		next_packet = pq_detach( packet );
 		length = packet_get_data_length( packet );
-		tmp_packet = pq_add( socket_data->incoming, packet, new_sequence_number, length );
-		if( ! tmp_packet ){
+		if( ERROR_OCCURRED( pq_add( & socket_data->incoming, packet, new_sequence_number, length ))){
 			// remove the corrupted packets
 			pq_release( tcp_globals.net_phone, packet_get_id( packet ));
 			pq_release( tcp_globals.net_phone, packet_get_id( next_packet ));
 		}else{
-			socket_data->incoming = tmp_packet;
 			while( next_packet ){
 				new_sequence_number += length;
@@ -939,5 +937,4 @@
 	packet_t	next;
 	packet_t	acknowledged = NULL;
-	packet_t	first;
 	uint32_t	old;
 
@@ -981,8 +978,5 @@
 					}
 					// add to acknowledged or release
-					first = pq_add( acknowledged, packet, 0, 0 );
-					if( first ){
-						acknowledged = first;
-					}else{
+					if( pq_add( & acknowledged, packet, 0, 0 ) != EOK ){
 						pq_release( tcp_globals.net_phone, packet_get_id( packet ));
 					}
@@ -1508,5 +1502,4 @@
 int	tcp_queue_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length ){
 	ERROR_DECLARE;
-	packet_t		first;
 
 	assert( socket );
@@ -1516,9 +1509,7 @@
 	ERROR_PROPAGATE( tcp_queue_prepare_packet( socket, socket_data, packet, data_length ));
 
-	first = pq_add( socket_data->outgoing, packet, socket_data->next_outgoing, data_length );
-	if( ! first ){
-		return tcp_release_and_return( packet, EINVAL );
-	}
-	socket_data->outgoing = first;
+	if( ERROR_OCCURRED( pq_add( & socket_data->outgoing, packet, socket_data->next_outgoing, data_length ))){
+		return tcp_release_and_return( packet, ERROR_CODE );
+	}
 	socket_data->next_outgoing += data_length;
 	return EOK;
Index: uspace/srv/net/tl/udp/udp.c
===================================================================
--- uspace/srv/net/tl/udp/udp.c	(revision bfd7aacc7de086de3588ff054d013521d83f6108)
+++ uspace/srv/net/tl/udp/udp.c	(revision 1e2e0c1eeb07d0d3faf4a5b53314c73e3b0c1a2a)
@@ -604,5 +604,7 @@
 			return udp_release_and_return( packet, result );
 		}
-		packet = pq_add( packet, next_packet, index, 0 );
+		if( ERROR_OCCURRED( pq_add( & packet, next_packet, index, 0 ))){
+			return udp_release_and_return( packet, ERROR_CODE );
+		}
 		total_length += ( size_t ) result;
 		if( udp_globals.checksum_computing ){
