aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-09-11 12:22:27 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 15:02:34 -0400
commit2bb6a12a88aeac9bab4ed0cf0da1edc03f5eb686 (patch)
tree7d81f9c9d2208af2df80c7fe2d5241c757d40a3f
parenta2279ae5b58edb7cbe2196d08572fcf59f292354 (diff)
Staging: dream: introduce missing kfree
Error handling code following a kmalloc or kzalloc should free the allocated data. The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @r exists@ local idexpression x; statement S; expression E; identifier f,f1,l; position p1,p2; expression *ptr != NULL; @@ x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...); ... if (x == NULL) S <... when != x when != if (...) { <+...x...+> } ( x->f1 = E | (x->f1 == NULL || ...) | f(...,x->f1,...) ) ...> ( return \(0\|<+...x...+>\|ptr\); | return@p2 ...; ) @script:python@ p1 << r.p1; p2 << r.p2; @@ print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk>
-rw-r--r--drivers/staging/dream/camera/msm_v4l2.c8
-rw-r--r--drivers/staging/dream/camera/msm_vfe8x_proc.c16
2 files changed, 18 insertions, 6 deletions
diff --git a/drivers/staging/dream/camera/msm_v4l2.c b/drivers/staging/dream/camera/msm_v4l2.c
index 46a6eb1cf53f..6a7d46cf11eb 100644
--- a/drivers/staging/dream/camera/msm_v4l2.c
+++ b/drivers/staging/dream/camera/msm_v4l2.c
@@ -521,13 +521,17 @@ static int msm_v4l2_s_fmt_cap(struct file *f,
521 ctrlcmd->value = pfmt; 521 ctrlcmd->value = pfmt;
522 ctrlcmd->timeout_ms = 10000; 522 ctrlcmd->timeout_ms = 10000;
523 523
524 if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 524 if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
525 kfree(ctrlcmd);
525 return -1; 526 return -1;
527 }
526 528
527#if 0 529#if 0
528 /* FIXEME */ 530 /* FIXEME */
529 if (pfmt->fmt.pix.pixelformat != V4L2_PIX_FMT_YVU420) 531 if (pfmt->fmt.pix.pixelformat != V4L2_PIX_FMT_YVU420) {
532 kfree(ctrlcmd);
530 return -EINVAL; 533 return -EINVAL;
534 }
531#endif 535#endif
532 536
533 /* Ok, but check other params, too. */ 537 /* Ok, but check other params, too. */
diff --git a/drivers/staging/dream/camera/msm_vfe8x_proc.c b/drivers/staging/dream/camera/msm_vfe8x_proc.c
index 5436f7120018..10aef0e59bab 100644
--- a/drivers/staging/dream/camera/msm_vfe8x_proc.c
+++ b/drivers/staging/dream/camera/msm_vfe8x_proc.c
@@ -967,8 +967,10 @@ vfe_send_af_stats_msg(uint32_t afBufAddress)
967 /* fill message with right content. */ 967 /* fill message with right content. */
968 /* @todo This is causing issues, need further investigate */ 968 /* @todo This is causing issues, need further investigate */
969 /* spin_lock_irqsave(&ctrl->state_lock, flags); */ 969 /* spin_lock_irqsave(&ctrl->state_lock, flags); */
970 if (ctrl->vstate != VFE_STATE_ACTIVE) 970 if (ctrl->vstate != VFE_STATE_ACTIVE) {
971 kfree(msg);
971 goto af_stats_done; 972 goto af_stats_done;
973 }
972 974
973 msg->_d = VFE_MSG_ID_STATS_AUTOFOCUS; 975 msg->_d = VFE_MSG_ID_STATS_AUTOFOCUS;
974 msg->_u.msgStatsAf.afBuffer = afBufAddress; 976 msg->_u.msgStatsAf.afBuffer = afBufAddress;
@@ -1053,8 +1055,10 @@ static void vfe_send_awb_stats_msg(uint32_t awbBufAddress)
1053 /* fill message with right content. */ 1055 /* fill message with right content. */
1054 /* @todo This is causing issues, need further investigate */ 1056 /* @todo This is causing issues, need further investigate */
1055 /* spin_lock_irqsave(&ctrl->state_lock, flags); */ 1057 /* spin_lock_irqsave(&ctrl->state_lock, flags); */
1056 if (ctrl->vstate != VFE_STATE_ACTIVE) 1058 if (ctrl->vstate != VFE_STATE_ACTIVE) {
1059 kfree(msg);
1057 goto awb_stats_done; 1060 goto awb_stats_done;
1061 }
1058 1062
1059 msg->_d = VFE_MSG_ID_STATS_WB_EXP; 1063 msg->_d = VFE_MSG_ID_STATS_WB_EXP;
1060 msg->_u.msgStatsWbExp.awbBuffer = awbBufAddress; 1064 msg->_u.msgStatsWbExp.awbBuffer = awbBufAddress;
@@ -1483,8 +1487,10 @@ static void vfe_send_output2_msg(
1483 /* fill message with right content. */ 1487 /* fill message with right content. */
1484 /* @todo This is causing issues, need further investigate */ 1488 /* @todo This is causing issues, need further investigate */
1485 /* spin_lock_irqsave(&ctrl->state_lock, flags); */ 1489 /* spin_lock_irqsave(&ctrl->state_lock, flags); */
1486 if (ctrl->vstate != VFE_STATE_ACTIVE) 1490 if (ctrl->vstate != VFE_STATE_ACTIVE) {
1491 kfree(msg);
1487 goto output2_msg_done; 1492 goto output2_msg_done;
1493 }
1488 1494
1489 msg->_d = VFE_MSG_ID_OUTPUT2; 1495 msg->_d = VFE_MSG_ID_OUTPUT2;
1490 1496
@@ -1518,8 +1524,10 @@ static void vfe_send_output1_msg(
1518 1524
1519 /* @todo This is causing issues, need further investigate */ 1525 /* @todo This is causing issues, need further investigate */
1520 /* spin_lock_irqsave(&ctrl->state_lock, flags); */ 1526 /* spin_lock_irqsave(&ctrl->state_lock, flags); */
1521 if (ctrl->vstate != VFE_STATE_ACTIVE) 1527 if (ctrl->vstate != VFE_STATE_ACTIVE) {
1528 kfree(msg);
1522 goto output1_msg_done; 1529 goto output1_msg_done;
1530 }
1523 1531
1524 msg->_d = VFE_MSG_ID_OUTPUT1; 1532 msg->_d = VFE_MSG_ID_OUTPUT1;
1525 memmove(&(msg->_u), 1533 memmove(&(msg->_u),