• Ronnie Sahlberg's avatar
    cifs: allow calling SMB2_xxx_free(NULL) · 32a1fb36
    Ronnie Sahlberg authored
    Change these free functions to allow passing NULL as the argument and
    treat it as a no-op just like free(NULL) would.
    Or, if rqst->rq_iov is NULL.
    
    The second scenario could happen for smb2_queryfs() if the call
    to SMB2_query_info_init() fails and we go to qfs_exit to clean up
    and free all resources.
    In that case we have not yet assigned rqst[2].rq_iov and thus
    the rq_iov dereference in SMB2_close_free() will cause a NULL pointer
    dereference.
    
    Fixes:  1eb9fb52 ("cifs: create SMB2_open_init()/SMB2_open_free() helpers")
    Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
    Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
    CC: Stable <stable@vger.kernel.org>
    32a1fb36
smb2pdu.c 118 KB