From: Mariusz Kozlowski This patch does kmalloc + memset conversion to kzalloc and removes some redundant argument checks. fs/cifs/connect.c | 109282 -> 109078 (-204 bytes) fs/cifs/connect.o | 211804 -> 211576 (-228 bytes) Signed-off-by: Mariusz Kozlowski Signed-off-by: Andrew Morton --- fs/cifs/connect.c | 30 +++++++++++------------------- 1 files changed, 11 insertions(+), 19 deletions(-) diff -puN fs/cifs/connect.c~fs-cifs-connectc-kmalloc-memset-conversion-to-kzalloc fs/cifs/connect.c --- a/fs/cifs/connect.c~fs-cifs-connectc-kmalloc-memset-conversion-to-kzalloc +++ a/fs/cifs/connect.c @@ -676,10 +676,8 @@ multi_t2_fnd: server->ssocket = NULL; } /* buffer usuallly freed in free_mid - need to free it here on exit */ - if (bigbuf != NULL) - cifs_buf_release(bigbuf); - if (smallbuf != NULL) - cifs_small_buf_release(smallbuf); + cifs_buf_release(bigbuf); + cifs_small_buf_release(smallbuf); read_lock(&GlobalSMBSeslock); if (list_empty(&server->pending_mid_q)) { @@ -1909,8 +1907,8 @@ cifs_mount(struct super_block *sb, struc return rc; } - srvTcp = kmalloc(sizeof (struct TCP_Server_Info), GFP_KERNEL); - if (srvTcp == NULL) { + srvTcp = kzalloc(sizeof(struct TCP_Server_Info), GFP_KERNEL); + if (!srvTcp) { rc = -ENOMEM; sock_release(csocket); kfree(volume_info.UNC); @@ -1919,7 +1917,6 @@ cifs_mount(struct super_block *sb, struc FreeXid(xid); return rc; } else { - memset(srvTcp, 0, sizeof (struct TCP_Server_Info)); memcpy(&srvTcp->addr.sockAddr, &sin_server, sizeof (struct sockaddr_in)); atomic_set(&srvTcp->inFlight, 0); @@ -2154,8 +2151,8 @@ cifs_mount(struct super_block *sb, struc } } /* If find_unc succeeded then rc == 0 so we can not end */ - if (tcon) /* up accidently freeing someone elses tcon struct */ - tconInfoFree(tcon); + /* up accidently freeing someone elses tcon struct */ + tconInfoFree(tcon); if (existingCifsSes == NULL) { if (pSesInfo) { if ((pSesInfo->server) && @@ -2526,8 +2523,7 @@ CIFSSessSetup(unsigned int xid, struct c sesssetup_nomem: /* do not return an error on nomem for the info strings, since that could make reconnection harder, and reconnection might be needed to free memory */ - if (smb_buffer) - cifs_buf_release(smb_buffer); + cifs_buf_release(smb_buffer); return rc; } @@ -2865,8 +2861,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned i rc = -EIO; } - if (smb_buffer) - cifs_buf_release(smb_buffer); + cifs_buf_release(smb_buffer); return rc; } @@ -3279,8 +3274,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xi rc = -EIO; } - if (smb_buffer) - cifs_buf_release(smb_buffer); + cifs_buf_release(smb_buffer); return rc; } @@ -3433,8 +3427,7 @@ CIFSTCon(unsigned int xid, struct cifsSe ses->ipc_tid = smb_buffer_response->Tid; } - if (smb_buffer) - cifs_buf_release(smb_buffer); + cifs_buf_release(smb_buffer); return rc; } @@ -3485,8 +3478,7 @@ cifs_umount(struct super_block *sb, stru kfree(tmp); if (ses) schedule_timeout_interruptible(msecs_to_jiffies(500)); - if (ses) - sesInfoFree(ses); + sesInfoFree(ses); FreeXid(xid); return rc; /* BB check if we should always return zero here */ _