ksmbd: remove unneeded NULL check in the list iterator

Remove unneeded NULL check in the list iterator. And use
list_for_each_entry_safe instead of list_for_each_safe.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Namjae Jeon 2021-06-22 16:16:45 +09:00
parent ee81cae1a6
commit 560ac05130
2 changed files with 6 additions and 9 deletions

View File

@ -30,15 +30,12 @@ struct ksmbd_session_rpc {
static void free_channel_list(struct ksmbd_session *sess)
{
struct channel *chann;
struct list_head *tmp, *t;
struct channel *chann, *tmp;
list_for_each_safe(tmp, t, &sess->ksmbd_chann_list) {
chann = list_entry(tmp, struct channel, chann_list);
if (chann) {
list_del(&chann->chann_list);
kfree(chann);
}
list_for_each_entry_safe(chann, tmp, &sess->ksmbd_chann_list,
chann_list) {
list_del(&chann->chann_list);
kfree(chann);
}
}

View File

@ -76,7 +76,7 @@ struct channel *lookup_chann_list(struct ksmbd_session *sess, struct ksmbd_conn
struct channel *chann;
list_for_each_entry(chann, &sess->ksmbd_chann_list, chann_list) {
if (chann && chann->conn == conn)
if (chann->conn == conn)
return chann;
}