OSDN Git Service

iscsi-target: Don't over-allocate sendtargets text resp buffer
authorSagi Grimberg <sagig@mellanox.com>
Mon, 26 Jan 2015 10:49:06 +0000 (12:49 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 4 Feb 2015 18:55:33 +0000 (10:55 -0800)
No reason to allocate a buffer of size bigger than initiator
MaxRecvDataSegmentLength. Moreover, we need to respect initiator
MRDSL and not send a larger payload.

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target.c

index 5b25faa..75c29b6 100644 (file)
@@ -3397,7 +3397,7 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
        unsigned char buf[ISCSI_IQN_LEN+12]; /* iqn + "TargetName=" + \0 */
        unsigned char *text_in = cmd->text_in_ptr, *text_ptr = NULL;
 
-       buffer_len = max(conn->conn_ops->MaxRecvDataSegmentLength,
+       buffer_len = min(conn->conn_ops->MaxRecvDataSegmentLength,
                         SENDTARGETS_BUF_LIMIT);
 
        payload = kzalloc(buffer_len, GFP_KERNEL);