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 file 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 @@ -673,10 +673,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)) { @@ -1901,8 +1899,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); @@ -1911,7 +1909,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); @@ -2146,8 +2143,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) && @@ -2518,8 +2515,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; } @@ -2857,8 +2853,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned i rc = -EIO; } - if (smb_buffer) - cifs_buf_release(smb_buffer); + cifs_buf_release(smb_buffer); return rc; } @@ -3266,8 +3261,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xi rc = -EIO; } - if (smb_buffer) - cifs_buf_release(smb_buffer); + cifs_buf_release(smb_buffer); return rc; } @@ -3423,8 +3417,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; } @@ -3475,8 +3468,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 */ _