ice: Check root pointer for validity
authorAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Thu, 8 Aug 2019 14:39:34 +0000 (07:39 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 5 Sep 2019 15:13:40 +0000 (08:13 -0700)
ice_sched_get_tc_node uses pi->root without checking for NULL. Add a
check to prevent NULL pointer dereference.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_sched.c

index 79d64f9..fc624b7 100644 (file)
@@ -284,7 +284,7 @@ struct ice_sched_node *ice_sched_get_tc_node(struct ice_port_info *pi, u8 tc)
 {
        u8 i;
 
-       if (!pi)
+       if (!pi || !pi->root)
                return NULL;
        for (i = 0; i < pi->root->num_children; i++)
                if (pi->root->children[i]->tc_num == tc)