mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-13 11:48:58 -04:00
crypto: qat - validate service in rate limiting sysfs api
The sysfs interface 'qat_rl/srv' currently allows all valid services, even if a service is not configured for the device. This leads to a failure when attempting to add the SLA using 'qat_rl/sla_op'. Add a check using is_service_enabled() to ensure the requested service is enabled. If not, return -EINVAL to prevent invalid configurations. Signed-off-by: Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
f0ae287c50
commit
63fa7c4dc0
@@ -209,8 +209,7 @@ u32 adf_rl_get_sla_arr_of_type(struct adf_rl *rl_data, enum rl_node_type type,
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_service_enabled(struct adf_accel_dev *accel_dev,
|
||||
enum adf_base_services rl_srv)
|
||||
bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv)
|
||||
{
|
||||
enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(rl_srv);
|
||||
struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev);
|
||||
|
||||
@@ -175,5 +175,6 @@ u32 adf_rl_calculate_ae_cycles(struct adf_accel_dev *accel_dev, u32 sla_val,
|
||||
enum adf_base_services svc_type);
|
||||
u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val,
|
||||
enum adf_base_services svc_type);
|
||||
bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv);
|
||||
|
||||
#endif /* ADF_RL_H_ */
|
||||
|
||||
@@ -291,14 +291,22 @@ static ssize_t srv_show(struct device *dev, struct device_attribute *attr,
|
||||
static ssize_t srv_store(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct adf_accel_dev *accel_dev;
|
||||
unsigned int val;
|
||||
int ret;
|
||||
|
||||
accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
|
||||
if (!accel_dev)
|
||||
return -EINVAL;
|
||||
|
||||
ret = sysfs_match_string(rl_services, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
val = ret;
|
||||
if (!is_service_enabled(accel_dev, val))
|
||||
return -EINVAL;
|
||||
|
||||
ret = set_param_u(dev, SRV, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user