aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsrael Rukshin <[email protected]>2017-01-04 15:59:37 +0200
committerDoug Ledford <[email protected]>2017-01-24 11:30:14 -0500
commit0a475ef4226e305bdcffe12b401ca1eab06c4913 (patch)
tree33ebdae1128d56463839b10ad499dd14d59df48e
parentad8e66b4a80182174f73487ed25fd2140cf43361 (diff)
IB/srp: fix invalid indirect_sg_entries parameter value
After setting indirect_sg_entries module_param to huge value (e.g 500,000), srp_alloc_req_data() fails to allocate indirect descriptors for the request ring (kmalloc fails). This commit enforces the maximum value of indirect_sg_entries to be SG_MAX_SEGMENTS as signified in module param description. Fixes: 65e8617fba17 (scsi: rename SCSI_MAX_{SG, SG_CHAIN}_SEGMENTS) Fixes: c07d424d6118 (IB/srp: add support for indirect tables that don't fit in SRP_CMD) Cc: [email protected] # 4.7+ Signed-off-by: Israel Rukshin <[email protected]> Signed-off-by: Max Gurtovoy <[email protected]> Reviewed-by: Laurence Oberman <[email protected]> Reviewed-by: Bart Van Assche <[email protected]>-- Signed-off-by: Doug Ledford <[email protected]>
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 0f67cf909462..79bf48477ddb 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -3699,6 +3699,12 @@ static int __init srp_init_module(void)
indirect_sg_entries = cmd_sg_entries;
}
+ if (indirect_sg_entries > SG_MAX_SEGMENTS) {
+ pr_warn("Clamping indirect_sg_entries to %u\n",
+ SG_MAX_SEGMENTS);
+ indirect_sg_entries = SG_MAX_SEGMENTS;
+ }
+
srp_remove_wq = create_workqueue("srp_remove");
if (!srp_remove_wq) {
ret = -ENOMEM;