Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3258502yba; Mon, 8 Apr 2019 14:46:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWdFsNqpY8zZ1qekoibjRUdcmMtBrHAdHkv9nxADHaW2ge82TCZk3VgP0UdJSXklB/PR1o X-Received: by 2002:a63:ac12:: with SMTP id v18mr29200278pge.111.1554760000759; Mon, 08 Apr 2019 14:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554760000; cv=none; d=google.com; s=arc-20160816; b=vOyo0jphLvYk2UMbBYJXBclftoDJoqI3llQC0j092IuVwfjWzIfmXpJRQM9n8SUulV ujKan4Nxw6CfuqJf8ZXtyhF26oRasz5LMf4I4qU5oQ2ntnrVtFdhEQGmZJreRX4m8UPQ V7rpMhUa0MxfBUT5vyQGhUFf8OCkuWyE5xXZNy2HxgsIFvtIbGp5n7N684oxDR+QJHGU UgzDEoE9edZxA9JvO/+jEdeMjLPfnkMI0Qrht2Nhx75PMYy2yHCL83M+VnGQRlKGebi8 dKuuppLWwmStJin3vIMXQk6TZ7UNo+xEntdD8qeLZa2U+5qFl//EJhpuL6KPljiAMxYo Ye6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vxf6jf0I3TNkNsrZiapyq8fbjujSIosIG2y16ynybBA=; b=vjJWBD07YqlVOlYTXGtDoN6SeOr2i3V/3I7TNi5ymO9U5Z3sc+EFMz3GVBMyGi52DU ZV+aVfzzuUGr1XFBzGkEfq2lWW1WAJDDwtrdObtaGcChS9l8Xfb+Mrfi4c4WcsiMnqyG uySNdaJ5Kt9F6D+bqOas/QfkynJqhydcS3ztUmzgFRGY4QzzIxSSkt8evIoxms3nEfVF m4uzPKQYb7QeeNsZ3EMuu+wk9G1nTHjKn/QluLneJgYvfK2OEdvY8F1EVpperr47ihHF i/Dq3wBjS66LRYWhjkSnL4q2vOxs6j8ToNHCYXaH1NSrCYZM+P5gk+A1rjwhRy+AOvS1 uI0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kEd6eRqE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si27519836pgn.237.2019.04.08.14.46.25; Mon, 08 Apr 2019 14:46:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kEd6eRqE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726630AbfDHVom (ORCPT + 99 others); Mon, 8 Apr 2019 17:44:42 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44647 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbfDHVnK (ORCPT ); Mon, 8 Apr 2019 17:43:10 -0400 Received: by mail-lj1-f194.google.com with SMTP id h16so12592310ljg.11; Mon, 08 Apr 2019 14:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vxf6jf0I3TNkNsrZiapyq8fbjujSIosIG2y16ynybBA=; b=kEd6eRqE0z2WuDnDs75PDb7FoCwTYeelkZLzX0z2TqwCfxh+waChPeEgq6aCK9OpoY h1kHL8aToAd026GdN3VUqTlMVxIU4z3oKOYKy8CVU3VpIKibmaGb6bnXhJGDbyefryx+ 2bz4M5FxHg8R+qOzBo94YmUIvXUd/owjrvC62SC78g5apa+I5rwqKHpv8gQmYhbGENB/ PFzqcMEM8HNnTVvkrCphbfcnbzi4AKxs+L5otKtXHkzpbZGECc6N2enxLPja9RHftexX cMPbqaYNs9y51xZMsxMiakKFSDB75KlV2M99BDdL6peg2sqkedDm0BZUTcKb80UeFUea 0nig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vxf6jf0I3TNkNsrZiapyq8fbjujSIosIG2y16ynybBA=; b=uQxbzsBMqth+EFVwXxNl8BFoEV7DIMUW2OPr+Ze/zWSHBQMWN9ZxFTJNQfIAbbc0Mp 94a0tDc61Cd9mu6NwOKxHFJHCJO+0PYWeZNs0iTyv+U/HOzg9NE0WZb2jrtbzKA3Cach lnF5Eqa9hd3FRHrWDuPuQ2J3PGKbazsI94GSCQNhM+87L0w8Alhm58qaNXkLh3af1us7 j3m6NVQSEf5xJf4x57fPxjhX3FHUSWQhmcYjrdb9+5c9v0NWPr5nm1ZCR43YENh7ZLsn 1FZUr/C0gmjcPFne8jSZHB1H/ynIMBM+4Lsp2PhKZ7EfQkFyXD5Nj7CssQtzbkuOZkD+ 9BTQ== X-Gm-Message-State: APjAAAWcNgA/qqrAOiwSxSwDjEmTDESgCBSZ0eI0CeEOOE0B558LPsFx d0ssCW6EDJZxRT6lZzjqWRU= X-Received: by 2002:a2e:380c:: with SMTP id f12mr18327410lja.116.1554759788393; Mon, 08 Apr 2019 14:43:08 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:07 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 02/14] media: ov6650: Fix control handler not freed on init error Date: Mon, 8 Apr 2019 23:42:30 +0200 Message-Id: <20190408214242.9603-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit afd9690c72c3 ("[media] ov6650: convert to the control framework"), if an error occurs during initialization of a control handler, resources possibly allocated to the handler are not freed before device initialiaton is aborted. Fix it. Fixes: afd9690c72c3 ("[media] ov6650: convert to the control framework") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index a3d00afcb0c8..007f0ca24913 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -992,8 +992,10 @@ static int ov6650_probe(struct i2c_client *client, V4L2_CID_GAMMA, 0, 0xff, 1, 0x12); priv->subdev.ctrl_handler = &priv->hdl; - if (priv->hdl.error) - return priv->hdl.error; + if (priv->hdl.error) { + ret = priv->hdl.error; + goto ectlhdlfree; + } v4l2_ctrl_auto_cluster(2, &priv->autogain, 0, true); v4l2_ctrl_auto_cluster(3, &priv->autowb, 0, true); @@ -1012,8 +1014,10 @@ static int ov6650_probe(struct i2c_client *client, priv->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; ret = v4l2_async_register_subdev(&priv->subdev); - if (ret) - v4l2_ctrl_handler_free(&priv->hdl); + if (!ret) + return 0; +ectlhdlfree: + v4l2_ctrl_handler_free(&priv->hdl); return ret; } -- 2.21.0