Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a475ef4 authored by Israel Rukshin's avatar Israel Rukshin Committed by Doug Ledford
Browse files

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: 65e8617f (scsi: rename SCSI_MAX_{SG, SG_CHAIN}_SEGMENTS)
Fixes: c07d424d (IB/srp: add support for indirect tables that don't fit in SRP_CMD)
Cc: stable@vger.kernel.org # 4.7+
Signed-off-by: default avatarIsrael Rukshin <israelr@mellanox.com>
Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Reviewed-by: default avatarLaurence Oberman <loberman@redhat.com>
Reviewed-by: default avatarBart Van Assche <bart.vanassche@sandisk.com&gt;-->
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent ad8e66b4
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -3699,6 +3699,12 @@ static int __init srp_init_module(void)
		indirect_sg_entries = cmd_sg_entries;
		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");
	srp_remove_wq = create_workqueue("srp_remove");
	if (!srp_remove_wq) {
	if (!srp_remove_wq) {
		ret = -ENOMEM;
		ret = -ENOMEM;