cifs: don't check for failure from mempool_alloc()

mempool_alloc() cannot fail if the gfp flags allow it to
sleep, and both GFP_FS allows for sleeping.

So these tests of the return value from mempool_alloc()
cannot be needed.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Steve French <smfrench@gmail.com>
This commit is contained in:
NeilBrown 2017-04-10 12:08:53 +10:00 committed by Steve French
parent 7d0c234fd2
commit a6f74e80f2
3 changed files with 31 additions and 43 deletions

View File

@ -167,13 +167,11 @@ cifs_buf_get(void)
/* clear the first few header bytes */ /* clear the first few header bytes */
/* for most paths, more is cleared in header_assemble */ /* for most paths, more is cleared in header_assemble */
if (ret_buf) { memset(ret_buf, 0, buf_size + 3);
memset(ret_buf, 0, buf_size + 3); atomic_inc(&bufAllocCount);
atomic_inc(&bufAllocCount);
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
atomic_inc(&totBufAllocCount); atomic_inc(&totBufAllocCount);
#endif /* CONFIG_CIFS_STATS2 */ #endif /* CONFIG_CIFS_STATS2 */
}
return ret_buf; return ret_buf;
} }
@ -201,15 +199,13 @@ cifs_small_buf_get(void)
albeit slightly larger than necessary and maxbuffersize albeit slightly larger than necessary and maxbuffersize
defaults to this and can not be bigger */ defaults to this and can not be bigger */
ret_buf = mempool_alloc(cifs_sm_req_poolp, GFP_NOFS); ret_buf = mempool_alloc(cifs_sm_req_poolp, GFP_NOFS);
if (ret_buf) {
/* No need to clear memory here, cleared in header assemble */ /* No need to clear memory here, cleared in header assemble */
/* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/ /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
atomic_inc(&smBufAllocCount); atomic_inc(&smBufAllocCount);
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
atomic_inc(&totSmBufAllocCount); atomic_inc(&totSmBufAllocCount);
#endif /* CONFIG_CIFS_STATS2 */ #endif /* CONFIG_CIFS_STATS2 */
}
return ret_buf; return ret_buf;
} }

View File

@ -538,23 +538,19 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
} }
temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS); temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS);
if (temp == NULL) memset(temp, 0, sizeof(struct mid_q_entry));
return temp; temp->mid = le64_to_cpu(shdr->MessageId);
else { temp->pid = current->pid;
memset(temp, 0, sizeof(struct mid_q_entry)); temp->command = shdr->Command; /* Always LE */
temp->mid = le64_to_cpu(shdr->MessageId); temp->when_alloc = jiffies;
temp->pid = current->pid; temp->server = server;
temp->command = shdr->Command; /* Always LE */
temp->when_alloc = jiffies;
temp->server = server;
/* /*
* The default is for the mid to be synchronous, so the * The default is for the mid to be synchronous, so the
* default callback just wakes up the current task. * default callback just wakes up the current task.
*/ */
temp->callback = cifs_wake_up_task; temp->callback = cifs_wake_up_task;
temp->callback_data = current; temp->callback_data = current;
}
atomic_inc(&midCount); atomic_inc(&midCount);
temp->mid_state = MID_REQUEST_ALLOCATED; temp->mid_state = MID_REQUEST_ALLOCATED;

View File

@ -55,26 +55,22 @@ AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
} }
temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS); temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS);
if (temp == NULL) memset(temp, 0, sizeof(struct mid_q_entry));
return temp; temp->mid = get_mid(smb_buffer);
else { temp->pid = current->pid;
memset(temp, 0, sizeof(struct mid_q_entry)); temp->command = cpu_to_le16(smb_buffer->Command);
temp->mid = get_mid(smb_buffer); cifs_dbg(FYI, "For smb_command %d\n", smb_buffer->Command);
temp->pid = current->pid;
temp->command = cpu_to_le16(smb_buffer->Command);
cifs_dbg(FYI, "For smb_command %d\n", smb_buffer->Command);
/* do_gettimeofday(&temp->when_sent);*/ /* easier to use jiffies */ /* do_gettimeofday(&temp->when_sent);*/ /* easier to use jiffies */
/* when mid allocated can be before when sent */ /* when mid allocated can be before when sent */
temp->when_alloc = jiffies; temp->when_alloc = jiffies;
temp->server = server; temp->server = server;
/* /*
* The default is for the mid to be synchronous, so the * The default is for the mid to be synchronous, so the
* default callback just wakes up the current task. * default callback just wakes up the current task.
*/ */
temp->callback = cifs_wake_up_task; temp->callback = cifs_wake_up_task;
temp->callback_data = current; temp->callback_data = current;
}
atomic_inc(&midCount); atomic_inc(&midCount);
temp->mid_state = MID_REQUEST_ALLOCATED; temp->mid_state = MID_REQUEST_ALLOCATED;