datapath: Check for NULL upcall_portids.
authorPravin B Shelar <pshelar@nicira.com>
Tue, 15 Jul 2014 18:12:11 +0000 (11:12 -0700)
committerPravin B Shelar <pshelar@nicira.com>
Tue, 15 Jul 2014 18:39:13 +0000 (11:39 -0700)
Following patch adds NULL check for memory allocated
by kmalloc.

Reported-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
datapath/vport.c

index 42ee726..5d250aa 100644 (file)
@@ -392,6 +392,9 @@ int ovs_vport_set_upcall_portids(struct vport *vport,  struct nlattr *ids)
 
        vport_portids = kmalloc(sizeof *vport_portids + nla_len(ids),
                                GFP_KERNEL);
+       if (!vport_portids)
+               return -ENOMEM;
+
        vport_portids->n_ids = nla_len(ids) / sizeof(u32);
        vport_portids->rn_ids = reciprocal_value(vport_portids->n_ids);
        nla_memcpy(vport_portids->ids, ids, nla_len(ids));