Commit 703ba885 authored by Colin Ian King's avatar Colin Ian King Committed by Jeff Kirsher

i40evf: dereference VSI after VSI has been null checked

VSI is being dereferenced before the VSI null check; if VSI is
null we end up with a null pointer dereference.  Fix this by
performing VSI deference after the VSI null check.  Also remove
the need for using adapter by using vsi->back->cinst.

Detected by CoverityScan, CID#1419696, CID#1419697
("Dereference before null check")

Fixes: ed0e894d ("i40evf: add client interface")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent c76cb6ed
...@@ -34,12 +34,12 @@ static struct i40e_ops i40evf_lan_ops = { ...@@ -34,12 +34,12 @@ static struct i40e_ops i40evf_lan_ops = {
**/ **/
void i40evf_notify_client_message(struct i40e_vsi *vsi, u8 *msg, u16 len) void i40evf_notify_client_message(struct i40e_vsi *vsi, u8 *msg, u16 len)
{ {
struct i40evf_adapter *adapter = vsi->back; struct i40e_client_instance *cinst;
struct i40e_client_instance *cinst = adapter->cinst;
if (!vsi) if (!vsi)
return; return;
cinst = vsi->back->cinst;
if (!cinst || !cinst->client || !cinst->client->ops || if (!cinst || !cinst->client || !cinst->client->ops ||
!cinst->client->ops->virtchnl_receive) { !cinst->client->ops->virtchnl_receive) {
dev_dbg(&vsi->back->pdev->dev, dev_dbg(&vsi->back->pdev->dev,
...@@ -58,12 +58,13 @@ void i40evf_notify_client_message(struct i40e_vsi *vsi, u8 *msg, u16 len) ...@@ -58,12 +58,13 @@ void i40evf_notify_client_message(struct i40e_vsi *vsi, u8 *msg, u16 len)
**/ **/
void i40evf_notify_client_l2_params(struct i40e_vsi *vsi) void i40evf_notify_client_l2_params(struct i40e_vsi *vsi)
{ {
struct i40evf_adapter *adapter = vsi->back; struct i40e_client_instance *cinst;
struct i40e_client_instance *cinst = adapter->cinst;
struct i40e_params params; struct i40e_params params;
if (!vsi) if (!vsi)
return; return;
cinst = vsi->back->cinst;
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
params.mtu = vsi->netdev->mtu; params.mtu = vsi->netdev->mtu;
params.link_up = vsi->back->link_up; params.link_up = vsi->back->link_up;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment