Skip to contentSkip to conversation

staging/dream: fix memory leak in camera error path

PATCH New Pavel Machek 1 participant 1 message Nov 21, 2009 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 staging/dream: fix memory leak in camera error path

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

drivers/staging/dream/camera/msm_camera.c +3 -1
index 7d93877..87e118d 100644
@@ -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;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html