Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1215470

Re: Potential data race in psmouse_interrupt

From Dmitry Vyukov <dvyukov@google.com>
Newsgroups linux.kernel
Subject Re: Potential data race in psmouse_interrupt
Date 2015-08-28 19:40 +0200
Message-ID <q2vN8-1Ec-17@gated-at.bofh.it> (permalink)
References <pP26e-7TN-31@gated-at.bofh.it> <pP26e-7TN-29@gated-at.bofh.it> <pPoq8-7Bj-49@gated-at.bofh.it> <pPoT9-89c-33@gated-at.bofh.it> <pRybE-7dX-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello,

I am looking at this code in __ps2_command again:

/*
* The reset command takes a long time to execute.
*/
timeout = msecs_to_jiffies(command == PS2_CMD_RESET_BAT ? 4000 : 500);

timeout = wait_event_timeout(ps2dev->wait,
    !(READ_ONCE(ps2dev->flags) & PS2_FLAG_CMD1), timeout);

if (smp_load_acquire(&ps2dev->cmdcnt) &&
    !(smp_load_acquire(&ps2dev->flags) & PS2_FLAG_CMD1)) {
              timeout = ps2_adjust_timeout(ps2dev, command, timeout);
              wait_event_timeout(ps2dev->wait,
                        !(smp_load_acquire(&ps2dev->flags) &
PS2_FLAG_CMD), timeout);
}

if (param)
    for (i = 0; i < receive; i++)
              param[i] = ps2dev->cmdbuf[(receive - 1) - i];


Here are two moments I don't understand:
1. The last parameter of ps2_adjust_timeout is timeout in jiffies (it
is compared against 100ms). However, timeout is assigned to result of
wait_event_timeout, which returns 0 or 1. This does not make sense to
me. What am I missing?
2. This code pays great attention to timeouts, but in the end I don't
see how it handles timeouts. That is, if a timeout is happened, we
still copyout (garbage) from cmdbuf. What am I missing here?

Thank you
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Potential data race in psmouse_interrupt Dmitry Vyukov <dvyukov@google.com> - 2015-08-28 19:40 +0200
  Re: Potential data race in psmouse_interrupt Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-08-28 20:00 +0200
    Re: Potential data race in psmouse_interrupt Dmitry Vyukov <dvyukov@google.com> - 2015-08-28 20:10 +0200
      Re: Potential data race in psmouse_interrupt Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-08-28 20:40 +0200
        Re: Potential data race in psmouse_interrupt Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-08-28 20:40 +0200
        Re: Potential data race in psmouse_interrupt Dmitry Vyukov <dvyukov@google.com> - 2015-09-01 20:50 +0200
          Re: Potential data race in psmouse_interrupt Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-09-04 19:00 +0200
            Re: Potential data race in psmouse_interrupt Dmitry Vyukov <dvyukov@google.com> - 2015-09-04 21:40 +0200
              Re: Potential data race in psmouse_interrupt Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-09-04 22:30 +0200
                Re: Potential data race in psmouse_interrupt Dmitry Vyukov <dvyukov@google.com> - 2015-09-05 15:30 +0200

csiph-web