ISAPNP: don't unlock isapnp_cfg_mutex unless we've locked it first
Subsystems (3)
PATCH 1/1 ISAPNP: don't unlock isapnp_cfg_mutex unless we've locked it first
If isapnp_cfg_begin() fails, it returns without locking isapnp_cfg_mutex. Previously, we always unlocked the mutex, even if we haven't locked it first.
This patch checks the isapnp_cfg_begin() return value so we can just exit and avoid this locking error.
Found by the Linux Device Drivers Verification Project and reported by Alexander Strakh <[email protected]>.
---
drivers/pnp/isapnp/core.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-)
drivers/pnp/isapnp/core.c +14 -4
@@ -903,7 +903,10 @@ static int isapnp_get_resources(struct pnp_dev *dev)pnp_dbg (&dev->dev,"get resources\n" );pnp_init_resources (dev); -isapnp_cfg_begin (dev->card->number, dev->number); + ret =isapnp_cfg_begin (dev->card->number, dev->number); +if (ret) +return ret; + dev->active =isapnp_read_byte (ISAPNP_CFG_ACTIVATE );if (!dev->active) goto __end;
@@ -937,10 +940,13 @@ __end:static int isapnp_set_resources (struct pnp_dev *dev) {struct resource *res; -int tmp; +int tmp, ret;pnp_dbg (&dev->dev,"set resources\n" ); -isapnp_cfg_begin (dev->card->number, dev->number); + ret =isapnp_cfg_begin (dev->card->number, dev->number); +if (ret) +return ret; + dev->active =1 ;for (tmp =0 ; tmp <ISAPNP_MAX_PORT ; tmp++) { res =pnp_get_resource (dev,IORESOURCE_IO , tmp);
@@ -986,9 +992,13 @@ static int isapnp_set_resources(struct pnp_dev *dev)static int isapnp_disable_resources (struct pnp_dev *dev) { +int ret; +if (!dev->active)return -EINVAL ; -isapnp_cfg_begin (dev->card->number, dev->number); + ret =isapnp_cfg_begin (dev->card->number, dev->number); +if (ret) +return ret;isapnp_deactivate (dev->number); dev->active =0 ;isapnp_cfg_end ();
Quoted 5 lines · Bjorn Helgaas
If
isapnp_cfg_begin()fails, it returns without lockingisapnp_cfg_mutex. Previously, we always unlocked the mutex, even if we haven't locked it first.
Quoted 7 lines
This patch checks the
isapnp_cfg_begin()return value so we can just exit and avoid this locking error.Found by the Linux Device Drivers Verification Project and reported by Alexander Strakh <[email protected]>.
Signed-off-by Bjorn Helgaas <[email protected]>
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.