[PATCH 0/2] comedi: comedi_bond: Prevent loops of bonded devices

Ian Abbott posted 2 patches 3 months, 1 week ago
drivers/comedi/drivers/comedi_bond.c        |   4 +-
drivers/comedi/kcomedilib/kcomedilib_main.c | 120 ++++++++++++++++++++++++++--
include/linux/comedi/comedilib.h            |  34 +++++++-
3 files changed, 149 insertions(+), 9 deletions(-)
[PATCH 0/2] comedi: comedi_bond: Prevent loops of bonded devices
Posted by Ian Abbott 3 months, 1 week ago
The "comedi_bond" driver allows a COMEDI device to be set up that uses
(or "bonds") the subdevices of another COMEDI device.  But by
reconfiguring that other COMEDI device to bond to the subdevices of the
first COMEDI device, it is possible to form a loop of bonded devices.
We want to avoid that because it is is both silly, and will result in
mutex deadlocks when accessing the channels of the bonded devices.

This series of patches introduces variants of the `comedi_open()` and
`comedi_close()` functions in the "kcomedilib" module that indicate
which COMEDI device is attempting to open the other COMEDI device, so
that this information can be saved by the "kcomedilib" and used to check
for and prevent cycles of devices opening each other.  The "comedi_bond"
driver module is changed to use these variant functions (called
`comedi_open_from()` and `comedi_close_from()`).

1) comedi: kcomedilib: Add loop checking variants of open and close
2) comedi: comedi_bond: Check for loops when bonding devices

 drivers/comedi/drivers/comedi_bond.c        |   4 +-
 drivers/comedi/kcomedilib/kcomedilib_main.c | 120 ++++++++++++++++++++++++++--
 include/linux/comedi/comedilib.h            |  34 +++++++-
 3 files changed, 149 insertions(+), 9 deletions(-)