Re: [PATCH] cli()/sti() fix for drivers/net/depca.c

From: Francois Romieu (romieu@cogenit.fr)
Date: Wed Oct 02 2002 - 15:40:59 EST


Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua> :
> diff -u --recursive linux-2.5.38orig/drivers/net/depca.c linux-2.5.38/drivers/net/depca.c
> --- linux-2.5.38orig/drivers/net/depca.c Sun Sep 22 04:25:10 2002
> +++ linux-2.5.38/drivers/net/depca.c Wed Oct 2 01:16:57 2002
[...]
> @@ -1999,18 +2000,19 @@
> break;
>
> case DEPCA_GET_STATS: /* Get the driver statistics */
> - cli();
> +
> + spin_lock_irqsave(&lp->lock, flags);
> ioc->len = sizeof(lp->pktStats);
> if (copy_to_user(ioc->data, &lp->pktStats, ioc->len))
> status = -EFAULT;
> - sti();
> + spin_unlock_irqrestore(&lp->lock, flags);

- copy_to_user() may sleep. Sleeping with spinlock held hurts badly.
- on SMP, pktStat can be updated while the copy progresses, see depca_rx().

-- 
Ueimor
-
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/



This archive was generated by hypermail 2b29 : Mon Oct 07 2002 - 22:00:35 EST