diff mbox series

cifs: allow calling SMB2_xxx_free(NULL)

Message ID 20181024013855.18334-1-lsahlber@redhat.com (mailing list archive)
State New, archived
Headers show
Series cifs: allow calling SMB2_xxx_free(NULL) | expand

Commit Message

Ronnie Sahlberg Oct. 24, 2018, 1:38 a.m. UTC
Change these free functions to allow passing NULL as the argument and
treat it as a no-op just like free(NULL) would.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/smb2pdu.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Comments

Aurélien Aptel Oct. 24, 2018, 9:45 a.m. UTC | #1
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
diff mbox series

Patch

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 5a08c8f6a322..167082532357 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2243,10 +2243,12 @@  SMB2_open_free(struct smb_rqst *rqst)
 {
 	int i;
 
-	cifs_small_buf_release(rqst->rq_iov[0].iov_base);
-	for (i = 1; i < rqst->rq_nvec; i++)
-		if (rqst->rq_iov[i].iov_base != smb2_padding)
-			kfree(rqst->rq_iov[i].iov_base);
+	if (rqst) {
+		cifs_small_buf_release(rqst->rq_iov[0].iov_base);
+		for (i = 1; i < rqst->rq_nvec; i++)
+			if (rqst->rq_iov[i].iov_base != smb2_padding)
+				kfree(rqst->rq_iov[i].iov_base);
+	}
 }
 
 int
@@ -2536,7 +2538,8 @@  SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
 void
 SMB2_close_free(struct smb_rqst *rqst)
 {
-	cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */
+	if (rqst)
+		cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */
 }
 
 int
@@ -2689,7 +2692,8 @@  SMB2_query_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
 void
 SMB2_query_info_free(struct smb_rqst *rqst)
 {
-	cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */
+	if (rqst)
+		cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */
 }
 
 static int
@@ -3803,7 +3807,8 @@  SMB2_set_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
 void
 SMB2_set_info_free(struct smb_rqst *rqst)
 {
-	cifs_buf_release(rqst->rq_iov[0].iov_base); /* request */
+	if (rqst)
+		cifs_buf_release(rqst->rq_iov[0].iov_base); /* request */
 }
 
 static int