• Varun Prakash's avatar
    iscsi-target: fix memory leak in iscsit_setup_text_cmd() · 3c21f983
    Varun Prakash authored
    [ Upstream commit ea8dc5b4 ]
    
    On receiving text request iscsi-target allocates buffer for
    payload in iscsit_handle_text_cmd() and assigns buffer pointer
    to cmd->text_in_ptr, this buffer is currently freed in
    iscsit_release_cmd(), if iscsi-target sets 'C' bit in text
    response then it will receive another text request from the
    initiator with ttt != 0xffffffff in this case iscsi-target
    will find cmd using itt and call iscsit_setup_text_cmd()
    which will set cmd->text_in_ptr to NULL without freeing
    previously allocated buffer.
    
    This patch fixes this issue by calling kfree(cmd->text_in_ptr)
    in iscsit_setup_text_cmd() before assigning NULL to it.
    
    For the first text request cmd->text_in_ptr is NULL as
    cmd is memset to 0 in iscsit_allocate_cmd().
    Signed-off-by: default avatarVarun Prakash <varun@chelsio.com>
    Cc: <stable@vger.kernel.org> # 4.0+
    Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
    3c21f983
iscsi_target.c 131 KB