[ovs-dev,v2,07/11] datapath: meter: fix NULL pointer dereference in ovs_meter_cmd_reply_start

Message ID 1518018601-31980-8-git-send-email-gvrose8192@gmail.com
State Accepted
Headers show
  • Add upstream Linux 4.14 kernel support
Related show

Commit Message

Gregory Rose Feb. 7, 2018, 3:49 p.m.
From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>

Upstream commit:
    commit b74912a2fdae9aadd20da502644aa8848c861954
    Author: Gustavo A. R. Silva <garsilva@embeddedor.com>
    Date:   Tue Nov 14 14:26:16 2017 -0600

    openvswitch: meter: fix NULL pointer dereference in ovs_meter_cmd_reply_star

    It seems that the intention of the code is to null check the value
    returned by function genlmsg_put. But the current code is null
    checking the address of the pointer that holds the value returned
    by genlmsg_put.

    Fix this by properly null checking the value returned by function
    genlmsg_put in order to avoid a pontential null pointer dereference.

    Addresses-Coverity-ID: 1461561 ("Dereference before null check")
    Addresses-Coverity-ID: 1461562 ("Dereference null return value")
    Fixes: 96fbc13d7e77 ("openvswitch: Add meter infrastructure")
    Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
 datapath/meter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/datapath/meter.c b/datapath/meter.c
index 7b9391d..d36870b 100644
--- a/datapath/meter.c
+++ b/datapath/meter.c
@@ -99,7 +99,7 @@  ovs_meter_cmd_reply_start(struct genl_info *info, u8 cmd,
 	*ovs_reply_header = genlmsg_put(skb, info->snd_portid,
 					&dp_meter_genl_family, 0, cmd);
-	if (!ovs_reply_header) {
+	if (!*ovs_reply_header) {
 		return ERR_PTR(-EMSGSIZE);