From: Paulo Alcantara Date: Mon, 19 Dec 2022 13:21:50 +0000 (-0300) Subject: cifs: don't leak -ENOMEM in smb2_open_file() X-Git-Tag: v6.1.8~1039 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae6fb31c0086dfe468a63c346ff55a86ed9950c7;p=platform%2Fkernel%2Flinux-starfive.git cifs: don't leak -ENOMEM in smb2_open_file() [ Upstream commit f60ffa662d1427cfd31fe9d895c3566ac50bfe52 ] A NULL error response might be a valid case where smb2_reconnect() failed to reconnect the session and tcon due to a disconnected server prior to issuing the I/O operation, so don't leak -ENOMEM to userspace on such occasions. Fixes: 76894f3e2f71 ("cifs: improve symlink handling for smb2+") Signed-off-by: Paulo Alcantara (SUSE) Signed-off-by: Steve French Signed-off-by: Sasha Levin --- diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index ffbd9a9..ba6cc50 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -122,8 +122,8 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32 struct smb2_hdr *hdr = err_iov.iov_base; if (unlikely(!err_iov.iov_base || err_buftype == CIFS_NO_BUFFER)) - rc = -ENOMEM; - else if (hdr->Status == STATUS_STOPPED_ON_SYMLINK) { + goto out; + if (hdr->Status == STATUS_STOPPED_ON_SYMLINK) { rc = smb2_parse_symlink_response(oparms->cifs_sb, &err_iov, &data->symlink_target); if (!rc) {