[ovs-dev] [PATCH 01/11] dp-packet: fix possible null pointer argument

William Tu u9012063 at gmail.com
Sat Oct 28 17:31:48 UTC 2017


Clang reports possible null pointer argument to the memcpy src.
This is due to at dp_packet_clone_data_with_headroom, the
dp_packet *b might have a NULL base due to allocating a dp_packet
with size = 0.  Fix it by adding ovs_assert to satisfy clang.

Signed-off-by: William Tu <u9012063 at gmail.com>
---
 lib/dp-packet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/dp-packet.c b/lib/dp-packet.c
index 443c22504379..f48e195a51d2 100644
--- a/lib/dp-packet.c
+++ b/lib/dp-packet.c
@@ -222,6 +222,7 @@ dp_packet_copy__(struct dp_packet *b, uint8_t *new_base,
     size_t copy_headroom = MIN(old_headroom, new_headroom);
     size_t copy_tailroom = MIN(old_tailroom, new_tailroom);
 
+    ovs_assert(old_base);
     memcpy(&new_base[new_headroom - copy_headroom],
            &old_base[old_headroom - copy_headroom],
            copy_headroom + dp_packet_size(b) + copy_tailroom);
-- 
2.7.4



More information about the dev mailing list