From: Colin Ian King Date: Fri, 17 May 2019 08:12:33 +0000 (+0100) Subject: cifs: fix memory leak of pneg_inbuf on -EOPNOTSUPP ioctl case X-Git-Tag: v4.19.49~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32d57c0c063cdab6639da074e8b0f28517862e41;p=platform%2Fkernel%2Flinux-rpi.git cifs: fix memory leak of pneg_inbuf on -EOPNOTSUPP ioctl case commit 210782038b54ec8e9059a3c12d6f6ae173efa3a9 upstream. Currently in the case where SMB2_ioctl returns the -EOPNOTSUPP error there is a memory leak of pneg_inbuf. Fix this by returning via the out_free_inbuf exit path that will perform the relevant kfree. Addresses-Coverity: ("Resource leak") Fixes: 969ae8e8d4ee ("cifs: Accept validate negotiate if server return NT_STATUS_NOT_SUPPORTED") CC: Stable # v5.1+ Signed-off-by: Colin Ian King Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 33afb63..c181f16 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -887,7 +887,8 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) * not supported error. Client should accept it. */ cifs_dbg(VFS, "Server does not support validate negotiate\n"); - return 0; + rc = 0; + goto out_free_inbuf; } else if (rc != 0) { cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc); rc = -EIO;