Re: [PATCH] broken locking in CPiA driver

Johannes Erdfelt (johannes@erdfelt.com)
Mon, 10 Sep 2001 20:16:28 -0400


On Mon, Sep 10, 2001, David C. Hansen <haveblue@us.ibm.com> wrote:
> This patch fixes a locking issue with the CPiA driver, and cleans up the
> locking. There is a potential race condition in cpia_pp_detach(). The
> REMOVE_FROM_LIST macro uses the BKL to provide protection for the
> cam_list. However, the BKL is not held during the whole for loop, only
> during the macro.
>
> This patch does several things:
> 1. rename REMOVE_FROM_LIST and ADD_TO_LIST to cpia_remove_from_list and
> cpia_add_to_list, respectively
> 2. make them "static inline" functions instead of #define macros. (take
> a look at this, they probably should be functions)
> 3. add one static spinlock cam_list_lock_{pp|usb} for each of the pp
> and usb drivers to replace BKL
> 4. do locking around all cam_list references to replace BKL locking
> from the macros
> 5. fix race condition
> 6. initialize cam_list to NULL in pp driver, just like the usb driver.

Technically this isn't a problem with USB since all connects and
disconnects are serialized, but it's probably worth the effort to
maintain consistency.

One lock for both PP and USB is probably sufficient.

They should also probably use the generic list.h routines.

JE

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