From patchwork Mon Apr 8 21:42:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61F9517E0 for ; Mon, 8 Apr 2019 21:44:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CBE928305 for ; Mon, 8 Apr 2019 21:44:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40FA828385; Mon, 8 Apr 2019 21:44:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0DCC28305 for ; Mon, 8 Apr 2019 21:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727160AbfDHVol (ORCPT ); Mon, 8 Apr 2019 17:44:41 -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-Google-Smtp-Source: APXvYqzF+x9ytABIqa1o88uB0Zp0yJSvBJXKEgO47uCtT1EVk1NKFlUbXcwp1Q/VV6hlVh6c+HPwTA== 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 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }