Commit cb79fa71 authored by Lukasz Czapnik's avatar Lukasz Czapnik Committed by Tony Nguyen
Browse files

i40e: add max boundary check for VF filters



There is no check for max filters that VF can request. Add it.

Fixes: e284fc28 ("i40e: Add and delete cloud filter")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarLukasz Czapnik <lukasz.czapnik@intel.com>
Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Tested-by: default avatarRafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 877b7e6f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3905,6 +3905,8 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
				       aq_ret);
}

#define I40E_MAX_VF_CLOUD_FILTER 0xFF00

/**
 * i40e_vc_add_cloud_filter
 * @vf: pointer to the VF info
@@ -3944,6 +3946,14 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg)
		goto err_out;
	}

	if (vf->num_cloud_filters >= I40E_MAX_VF_CLOUD_FILTER) {
		dev_warn(&pf->pdev->dev,
			 "VF %d: Max number of filters reached, can't apply cloud filter\n",
			 vf->vf_id);
		aq_ret = -ENOSPC;
		goto err_out;
	}

	cfilter = kzalloc(sizeof(*cfilter), GFP_KERNEL);
	if (!cfilter) {
		aq_ret = -ENOMEM;