Re: [PATCH 3/3] Bluetooth: Fix waiting for clearing of BT_SK_SUSPEND flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Lizardo,

On Fri, Sep 13, 2013, Anderson Lizardo wrote:
> On Fri, Sep 13, 2013 at 4:43 AM,  <johan.hedberg@xxxxxxxxx> wrote:
> > +int bt_sock_wait_unsuspend(struct sock *sk, unsigned long flags)
> > +{
> > +       DECLARE_WAITQUEUE(wait, current);
> > +       unsigned long timeo;
> > +       int err = 0;
> > +
> > +       BT_DBG("sk %p", sk);
> > +
> > +       timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
> > +
> > +       add_wait_queue(sk_sleep(sk), &wait);
> > +       set_current_state(TASK_INTERRUPTIBLE);
> > +       while (test_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags)) {
> > +               if (!timeo) {
> > +                       err = -EAGAIN;
> > +                       break;
> > +               }
> > +
> > +               if (signal_pending(current)) {
> > +                       err = sock_intr_errno(timeo);
> > +                       break;
> > +               }
> > +
> > +               release_sock(sk);
> > +               timeo = schedule_timeout(timeo);
> > +               lock_sock(sk);
> > +               set_current_state(TASK_INTERRUPTIBLE);
> > +
> > +               err = sock_error(sk);
> > +               if (err)
> > +                       break;
> > +       }
> > +       __set_current_state(TASK_RUNNING);
> > +       remove_wait_queue(sk_sleep(sk), &wait);
> > +       return err;
> > +}
> 
> You can add a blank line before "return err" for slightly better legibility.

Sure. The reason it's not there is that I followed the existing similar
bt_sock_wait_state function implementation.

> > @@ -559,9 +559,12 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
> >
> >         lock_sock(sk);
> >
> > +       err = bt_sock_wait_unsuspend(sk, msg->msg_flags);
> > +       if (err)
> > +               return err;
> > +
> 
> Is it okay to return without releasing the lock?

Nope, I'm pretty sure that's a bug. Good catch, I'll fix in a v2.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux