Re: [PATCH v2 2/3] smb/server: cancel async requests when closing connection

Namjae Jeon <[email protected]>
Newsgroups org.kernel.vger.linux-cifs
Message-ID <CAKYAXd80TEVZB2GYeYCfhhyN99HyD89ZP_9NjON6caoXuMWTDg@mail.gmail.com>
> +static void ksmbd_conn_cancel_async_requests(struct ksmbd_conn *conn)
> +{
> +       struct ksmbd_work *work;
> +
> +       ksmbd_debug(CONN, "Cancel pending async requests on releasing connection\n");
> +       spin_lock(&conn->request_lock);
> +       list_for_each_entry(work, &conn->async_requests, async_request_entry) {
smb2_notify_cancel_fn() calls list_del_init() on async_request_entry.
With list_for_each_entry(), the loop increment then follows the
self-linked entry again, causing an infinite loop while holding
request_lock ? So, should we use list_for_each_entry_safe() ?

> +               if (work->state != KSMBD_WORK_ACTIVE)
> +                       continue;
> +
> +               ksmbd_debug(CONN, "Cancel async request id %d\n",
> +                           work->async_id);
> +               work->state = KSMBD_WORK_CANCELLED;
> +               if (work->cancel_fn)
> +                       work->cancel_fn(work->cancel_argv);
> +       }
> +       spin_unlock(&conn->request_lock);
> +}
> +
>  void ksmbd_conn_lock(struct ksmbd_conn *conn)
>  {
>         mutex_lock(&conn->srv_mutex);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.