Browse Source

Staging: dream: fix memory leak in camera error path

cppcheck found that ctrl_pmsm is leaked if the open operation fails.

Signed-off-by: Eric Sesterhenn <eric.sesterhenn@lsexperts.de>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Pavel Machek 15 years ago
parent
commit
ccf972bd6b
1 changed files with 3 additions and 1 deletions
  1. 3 1
      drivers/staging/dream/camera/msm_camera.c

+ 3 - 1
drivers/staging/dream/camera/msm_camera.c

@@ -1885,8 +1885,10 @@ static int msm_open_control(struct inode *inode, struct file *filep)
 		return -ENOMEM;
 
 	rc = msm_open_common(inode, filep, 0);
-	if (rc < 0)
+	if (rc < 0) {
+		kfree(ctrl_pmsm);
 		return rc;
+	}
 
 	ctrl_pmsm->pmsm = filep->private_data;
 	filep->private_data = ctrl_pmsm;