cifs: replace code with free_rsp_buf()
authorSachin Prabhu <sprabhu@redhat.com>
Mon, 16 Jun 2014 14:35:24 +0000 (15:35 +0100)
committerSteve French <smfrench@gmail.com>
Fri, 1 Aug 2014 04:11:15 +0000 (23:11 -0500)
The functionality provided by free_rsp_buf() is duplicated in a number
of places. Replace these instances with a call to free_rsp_buf().

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Reviewed-by: Shirish Pargaonkar <spargaonkar@suse.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/cifsproto.h
fs/cifs/cifssmb.c
fs/cifs/misc.c
fs/cifs/smb2pdu.c

index ca7980a1e303b85d4ef85d2f615645371c1934f7..de49d7a37b00334700a1ff5acd3245757bf966ee 100644 (file)
@@ -36,6 +36,7 @@ extern struct smb_hdr *cifs_buf_get(void);
 extern void cifs_buf_release(void *);
 extern struct smb_hdr *cifs_small_buf_get(void);
 extern void cifs_small_buf_release(void *);
+extern void free_rsp_buf(int, void *);
 extern void cifs_rqst_page_to_kvec(struct smb_rqst *rqst, unsigned int idx,
                                        struct kvec *iov);
 extern int smb_send(struct TCP_Server_Info *, struct smb_hdr *,
index 6ce4e0954b986ac1dd40bfb6dd9a8a851bef68d1..b7e5b6508caafc3bc8397dde717e25dd505bdebf 100644 (file)
@@ -1734,10 +1734,7 @@ CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
 
 /*     cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
        if (*buf) {
-               if (resp_buf_type == CIFS_SMALL_BUFFER)
-                       cifs_small_buf_release(iov[0].iov_base);
-               else if (resp_buf_type == CIFS_LARGE_BUFFER)
-                       cifs_buf_release(iov[0].iov_base);
+               free_rsp_buf(resp_buf_type, iov[0].iov_base);
        } else if (resp_buf_type != CIFS_NO_BUFFER) {
                /* return buffer to caller to free */
                *buf = iov[0].iov_base;
@@ -2203,10 +2200,7 @@ CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
        }
 
 /*     cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
-       if (resp_buf_type == CIFS_SMALL_BUFFER)
-               cifs_small_buf_release(iov[0].iov_base);
-       else if (resp_buf_type == CIFS_LARGE_BUFFER)
-               cifs_buf_release(iov[0].iov_base);
+       free_rsp_buf(resp_buf_type, iov[0].iov_base);
 
        /* Note: On -EAGAIN error only caller can retry on handle based calls
                since file handle passed in no longer valid */
@@ -2451,10 +2445,7 @@ plk_err_exit:
        if (pSMB)
                cifs_small_buf_release(pSMB);
 
-       if (resp_buf_type == CIFS_SMALL_BUFFER)
-               cifs_small_buf_release(iov[0].iov_base);
-       else if (resp_buf_type == CIFS_LARGE_BUFFER)
-               cifs_buf_release(iov[0].iov_base);
+       free_rsp_buf(resp_buf_type, iov[0].iov_base);
 
        /* Note: On -EAGAIN error only caller can retry on handle based calls
           since file handle passed in no longer valid */
@@ -3838,10 +3829,7 @@ CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,
                }
        }
 qsec_out:
-       if (buf_type == CIFS_SMALL_BUFFER)
-               cifs_small_buf_release(iov[0].iov_base);
-       else if (buf_type == CIFS_LARGE_BUFFER)
-               cifs_buf_release(iov[0].iov_base);
+       free_rsp_buf(buf_type, iov[0].iov_base);
 /*     cifs_small_buf_release(pSMB); */ /* Freed earlier now in SendReceive2 */
        return rc;
 }
index 3b0c62e622da80b55d4e290c94ed1ec564699eed..64997a04ab59020326dc4481791f80d882eda82d 100644 (file)
@@ -226,6 +226,15 @@ cifs_small_buf_release(void *buf_to_free)
        return;
 }
 
+void
+free_rsp_buf(int resp_buftype, void *rsp)
+{
+       if (resp_buftype == CIFS_SMALL_BUFFER)
+               cifs_small_buf_release(rsp);
+       else if (resp_buftype == CIFS_LARGE_BUFFER)
+               cifs_buf_release(rsp);
+}
+
 /* NB: MID can not be set if treeCon not passed in, in that
    case it is responsbility of caller to set the mid */
 void
index b0b260dbb19dff021ad124fbad81322f51b8b69e..0158104df7456ae365bfce9fc33130bc24ee812d 100644 (file)
@@ -309,16 +309,6 @@ small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon,
        return rc;
 }
 
-static void
-free_rsp_buf(int resp_buftype, void *rsp)
-{
-       if (resp_buftype == CIFS_SMALL_BUFFER)
-               cifs_small_buf_release(rsp);
-       else if (resp_buftype == CIFS_LARGE_BUFFER)
-               cifs_buf_release(rsp);
-}
-
-
 /*
  *
  *     SMB2 Worker functions follow: