diff mbox

[ovs-dev,6/7] packets: Fix null pointer dereference reported by clang.

Message ID 1467176548-40488-7-git-send-email-u9012063@gmail.com
State Changes Requested
Headers show

Commit Message

William Tu June 29, 2016, 5:02 a.m. UTC
In packet_set_tcp_port(), clang reports passing null pointer of &th->tcp_src
when calling packet_set_port(&th->tcp_src, src, &th->tcp_csum);

Signed-off-by: William Tu <u9012063@gmail.com>
---
 lib/packets.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff July 3, 2016, 4:29 a.m. UTC | #1
On Tue, Jun 28, 2016 at 10:02:27PM -0700, William Tu wrote:
> In packet_set_tcp_port(), clang reports passing null pointer of &th->tcp_src
> when calling packet_set_port(&th->tcp_src, src, &th->tcp_csum);
> 
> Signed-off-by: William Tu <u9012063@gmail.com>

I don't see how this can happen.  If it can, it seems like there's a
more serious bug that we should fix.
diff mbox

Patch

diff --git a/lib/packets.c b/lib/packets.c
index 43b5a70..1d3f409 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -1036,7 +1036,7 @@  packet_set_ipv6(struct dp_packet *packet, const ovs_be32 src[4],
 static void
 packet_set_port(ovs_be16 *port, ovs_be16 new_port, ovs_be16 *csum)
 {
-    if (*port != new_port) {
+    if (port && *port != new_port) {
         *csum = recalc_csum16(*csum, *port, new_port);
         *port = new_port;
     }