Re: [PATCH 9 of 20] ipath - char devices for diagnostics and lightweight subnet management

From: Roland Dreier
Date: Thu Mar 09 2006 - 18:21:45 EST


> +static int ipath_sma_open(struct inode *in, struct file *fp)
> +{
> + int s;
> +
> + if (ipath_sma_alive) {
> + ipath_dbg("SMA already running (pid %u), failing\n",
> + ipath_sma_alive);
> + return -EBUSY;
> + }
> +
> + for (s = 0; s < atomic_read(&ipath_max); s++) {
> + struct ipath_devdata *dd = ipath_lookup(s);
> + /* we need at least one infinipath device to be initialized. */
> + if (dd && dd->ipath_flags & IPATH_INITTED) {
> + ipath_sma_alive = current->pid;

It seems there's a window here where two processes can both pass the
if (ipath_sma_alive) test and then proceed to step on each other.

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