dvb-core: Release semaphore on error path dvb_register_device().

Message ID 1340452794-8117-1-git-send-email-santoshprasadnayak@gmail.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

santosh nayak June 23, 2012, 11:59 a.m. UTC
  From: Santosh Nayak <santoshprasadnayak@gmail.com>

There is a missing "up_write()" here. Semaphore should be released
before returning error value.

Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
---
Destination tree "linux-next"

 drivers/media/dvb/dvb-core/dvbdev.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
  

Comments

Nikolaus Schulz June 23, 2012, 6:32 p.m. UTC | #1
CC'ing stable@kernel.org, this bugfix applies to all kernels >> 2.6.28.

The patch should also be tagged accordingly.

On Sat, Jun 23, 2012 at 05:29:54PM +0530, santosh nayak wrote:
> From: Santosh Nayak <santoshprasadnayak@gmail.com>
> 
> There is a missing "up_write()" here. Semaphore should be released
> before returning error value.
> 
> Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
> ---
> Destination tree "linux-next"
> 
>  drivers/media/dvb/dvb-core/dvbdev.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
> index 00a6732..39eab73 100644
> --- a/drivers/media/dvb/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb/dvb-core/dvbdev.c
> @@ -243,6 +243,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
>  	if (minor == MAX_DVB_MINORS) {
>  		kfree(dvbdevfops);
>  		kfree(dvbdev);
> +		up_write(&minor_rwsem);
>  		mutex_unlock(&dvbdev_register_lock);
>  		return -EINVAL;
>  	}
> -- 
> 1.7.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 00a6732..39eab73 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -243,6 +243,7 @@  int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 	if (minor == MAX_DVB_MINORS) {
 		kfree(dvbdevfops);
 		kfree(dvbdev);
+		up_write(&minor_rwsem);
 		mutex_unlock(&dvbdev_register_lock);
 		return -EINVAL;
 	}