diff mbox

[1/2] drm: restore open_count if drm_setup fails

Message ID 1351532101-8523-1-git-send-email-ihadzic@research.bell-labs.com (mailing list archive)
State Accepted
Headers show

Commit Message

Ilija Hadzic Oct. 29, 2012, 5:35 p.m. UTC
If drm_setup (called at first open) fails, the whole
open call has failed, so we should not keep the
open_count incremented.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/drm_fops.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Thomas Hellstrom Oct. 30, 2012, 1:51 p.m. UTC | #1
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>

On 10/29/2012 06:35 PM, Ilija Hadzic wrote:
> If drm_setup (called at first open) fails, the whole
> open call has failed, so we should not keep the
> open_count incremented.
>
> Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
> Cc: stable@vger.kernel.org
> ---
>   drivers/gpu/drm/drm_fops.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 7ef1b67..af68eca 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -135,8 +135,11 @@ int drm_open(struct inode *inode, struct file *filp)
>   	retcode = drm_open_helper(inode, filp, dev);
>   	if (!retcode) {
>   		atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
> -		if (!dev->open_count++)
> +		if (!dev->open_count++) {
>   			retcode = drm_setup(dev);
> +			if (retcode)
> +				dev->open_count--;
> +		}
>   	}
>   	if (!retcode) {
>   		mutex_lock(&dev->struct_mutex);
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 7ef1b67..af68eca 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -135,8 +135,11 @@  int drm_open(struct inode *inode, struct file *filp)
 	retcode = drm_open_helper(inode, filp, dev);
 	if (!retcode) {
 		atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
-		if (!dev->open_count++)
+		if (!dev->open_count++) {
 			retcode = drm_setup(dev);
+			if (retcode)
+				dev->open_count--;
+		}
 	}
 	if (!retcode) {
 		mutex_lock(&dev->struct_mutex);