From patchwork Thu Jul 28 07:59:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1014672 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6S80AIR024087 for ; Thu, 28 Jul 2011 08:00:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755081Ab1G1IAI (ORCPT ); Thu, 28 Jul 2011 04:00:08 -0400 Received: from mga09.intel.com ([134.134.136.24]:63020 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755054Ab1G1IAH (ORCPT ); Thu, 28 Jul 2011 04:00:07 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 28 Jul 2011 01:00:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,281,1309762800"; d="scan'208";a="32995136" Received: from unknown (HELO smile) ([10.255.17.225]) by orsmga001.jf.intel.com with ESMTP; 28 Jul 2011 01:00:05 -0700 Received: from andy by smile with local (Exim 4.76) (envelope-from ) id 1QmLVY-0002H0-7c; Thu, 28 Jul 2011 10:59:52 +0300 From: Andy Shevchenko To: linux-media@vger.kernel.org Cc: Andy Shevchenko , Sakari Ailus Subject: [PATCHv2] adp1653: check error code of adp1653_init_controls Date: Thu, 28 Jul 2011 10:59:38 +0300 Message-Id: <4db811899ccd7b5315080790a627974e3569c7cc.1311839940.git.andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <20110727081522.GH32629@valkosipuli.localdomain> References: <20110727081522.GH32629@valkosipuli.localdomain> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Jul 2011 08:00:11 +0000 (UTC) Potentially the adp1653_init_controls could return an error. In our case the error was ignored, meanwhile it means incorrect initialization of V4L2 controls. Additionally we have to free control handler structures in case of apd1653_init_controls or media_entity_init failure. Signed-off-by: Andy Shevchenko Cc: Sakari Ailus --- drivers/media/video/adp1653.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/adp1653.c b/drivers/media/video/adp1653.c index 8ad89ff..279d75d 100644 --- a/drivers/media/video/adp1653.c +++ b/drivers/media/video/adp1653.c @@ -429,12 +429,19 @@ static int adp1653_probe(struct i2c_client *client, flash->subdev.internal_ops = &adp1653_internal_ops; flash->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - adp1653_init_controls(flash); + ret = adp1653_init_controls(flash); + if (ret) + goto free_and_quit; ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0); if (ret < 0) - kfree(flash); + goto free_and_quit; + return 0; + +free_and_quit: + v4l2_ctrl_handler_free(&flash->ctrls); + kfree(flash); return ret; }