From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F9C9C2D0DA for ; Sun, 29 Dec 2019 17:44:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40ADF208C4 for ; Sun, 29 Dec 2019 17:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641480; bh=xVob68oSu11Sx6EtlR/btwB5rrUHSdWRvF6U7ehhS/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NrJT2l+AskMxm9MjODeSSI7rUH+EvT4lHJ5rl8+69Oxu8MOvoJ4Nl+m6ugwWkcjXl kj4uAGK2LIYsYM8G2b0FF+vU8sUA9gP45D65ABlmkzQ2QqmqwTWMjE6juluuhFXxkM Pc1pJ5pb6NrEemS1aaE1Oo1jAQLp5YobfBX7QS30= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730722AbfL2Roe (ORCPT ); Sun, 29 Dec 2019 12:44:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:52784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730718AbfL2Roe (ORCPT ); Sun, 29 Dec 2019 12:44:34 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 60A5721744; Sun, 29 Dec 2019 17:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641473; bh=xVob68oSu11Sx6EtlR/btwB5rrUHSdWRvF6U7ehhS/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rMw5a2ZEPyex8ha/I2f4p/B8roBatTy6Qht3cDPnSDqn1iX4zF4/qJQyBmn+e0D6p IcFmwKc7OPC+LqphFTvWR0L+Cv4wesfa7I4Ob4Yl9Ig7sS8GpD4mTbLkuloXc+iS1f 34o+fwAUIuxTCHIwyLFsvW2DgdDKONF+DrF2kCyk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janusz Krzysztofik , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 080/434] media: ov6650: Fix control handler not freed on init error Date: Sun, 29 Dec 2019 18:22:13 +0100 Message-Id: <20191229172706.901008936@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Janusz Krzysztofik [ Upstream commit c404af950d14b71bfbf574a752b6c29d726baaba ] 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 Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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 5b9af5e5b7f1..68776b0710f9 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -989,8 +989,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); @@ -1008,8 +1010,10 @@ static int ov6650_probe(struct i2c_client *client, priv->subdev.internal_ops = &ov6650_internal_ops; 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.20.1