From: Venkat Duvvuru Date: Thu, 4 Jan 2018 23:46:55 +0000 (-0500) Subject: bnxt_en: Fix the 'Invalid VF' id check in bnxt_vf_ndo_prep routine. X-Git-Tag: v4.1.12-124.31.3~929 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=271213d17c7fc485575a86b1deb489d1a88ce177;p=users%2Fjedix%2Flinux-maple.git bnxt_en: Fix the 'Invalid VF' id check in bnxt_vf_ndo_prep routine. Orabug: 27648355, 27648339 In bnxt_vf_ndo_prep (which is called by bnxt_get_vf_config ndo), there is a check for "Invalid VF id". Currently, the check is done against max_vfs. However, the user doesn't always create max_vfs. So, the check should be against the created number of VFs. The number of bnxt_vf_info structures that are allocated in bnxt_alloc_vf_resources routine is the "number of requested VFs". So, if an "invalid VF id" falls between the requested number of VFs and the max_vfs, the driver will be dereferencing an invalid pointer. Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Signed-off-by: Venkat Devvuru Signed-off-by: Michael Chan Signed-off-by: David S. Miller (cherry picked from commit 78f300049335ae81a5cc6b4b232481dc5e1f9d41) Signed-off-by: Brian Maly Reviewed-by: Jack Vogel --- diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c index 3a9388e02d78..f1d4a5f92b0a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c @@ -69,7 +69,7 @@ static int bnxt_vf_ndo_prep(struct bnxt *bp, int vf_id) netdev_err(bp->dev, "vf ndo called though sriov is disabled\n"); return -EINVAL; } - if (vf_id >= bp->pf.max_vfs) { + if (vf_id >= bp->pf.active_vfs) { netdev_err(bp->dev, "Invalid VF id %d\n", vf_id); return -EINVAL; }