Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2860137pxb; Mon, 18 Apr 2022 09:44:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwobjaY/MrY4bofBIuUtU7svh3Lext8D+ljdXeXbeqkCTjSkaW81VP4VF53jyLjTiPw5xuf X-Received: by 2002:a17:906:478d:b0:6e8:8ee0:1f9f with SMTP id cw13-20020a170906478d00b006e88ee01f9fmr9670218ejc.296.1650300279958; Mon, 18 Apr 2022 09:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650300279; cv=none; d=google.com; s=arc-20160816; b=oT7jWCLXtv0vGRjdsF6R1gUdSdjyDIcgNRYSz6ZkqgFLeAjEhxal02CCB9e7YE6n46 HlsWn3FsX1Ln3DGzFZN53YqFO8CvShryBKQmu1iZtig8YsOHaq8etm3tB9quJIMSmG5s cQ7KNapnZLzhJo9m+gH1l6LkVQAMGyKcD+PEUrOA8pD8PGGxnBH9GE1iiIznIsBkDCmV 1kwJ3RvJrPGPEtZ4nB26XUOHU3nSRuanInJY3NymAthizS/AamI0ltpZLZvz8yCP3PC5 pLAk+vgfapi9ZG0Jlg2bkA9GRkV/zYvgsLvqhKkaEOJstC39FQZhcCCFhM3dMXt8xwjB SYuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0WnQbZiAfLfLuDF4204oRlGISwNlkcLrg7moX68zSAQ=; b=aTpCnMqYIu9khQFxHzfzJkSXWJ2yLDZQTVQE2MZRFjlWNvC54yBaiHpK7VQjbO+vfG frJLAkzWglB8yMi1bUqTJaV6KhdQ0ZAAwDrpg5Sv1Z1SBPBgYZMMyHw77Ifr5vyLhlLO RqXquXvfpbWgQx90DSADEe8638htUY+uU18G+MgLjsu6T8dCm1NoedBscSegp/WI9Bam 3KIWMbq8C55h4DJVlPi2e3snN0/PAlJ7PL28gv/JEfe+T3r/30B/jbatdaLrEKxWRfVc CbXhzcKdL22S53qjvsItRXeUff9A1yHJjwpf+DqEQgRO9kcybibOvUo89+fvwvaRHuK4 p4lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sIW7wbJ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a170906495200b006dfad24c60csi6393329ejt.249.2022.04.18.09.44.15; Mon, 18 Apr 2022 09:44:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sIW7wbJ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243224AbiDRNlp (ORCPT + 99 others); Mon, 18 Apr 2022 09:41:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241934AbiDRNNH (ORCPT ); Mon, 18 Apr 2022 09:13:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60A9639BB8; Mon, 18 Apr 2022 05:50:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BB1D86128D; Mon, 18 Apr 2022 12:50:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3368C385A8; Mon, 18 Apr 2022 12:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286255; bh=wq+2Jo2ycQGQ6rd/zMFPBA3/65ZNrOu88pNHJPRppgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sIW7wbJ7143pco4oO0+btrxMtnbORnUDJ56IXXYUfUwBxIhXRLhwwXUx1NVzVu15U yOqjQ7YrAnlp+/6dkCh4itCvvlVbQfZxyrMYA+vA6pUdfcLj5JFe1mlKXbzrs2Wkyi fzdJDmntwYmDwUdOwYTrj0lFuVPtBDgKabi3Qcm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Hans Verkuil , Sasha Levin Subject: [PATCH 4.14 076/284] media: usb: go7007: s2250-board: fix leak in probe() Date: Mon, 18 Apr 2022 14:10:57 +0200 Message-Id: <20220418121212.848356319@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 67e4550ecd6164bfbdff54c169e5bbf9ccfaf14d ] Call i2c_unregister_device(audio) on this error path. Fixes: d3b2ccd9e307 ("[media] s2250: convert to the control framework") Signed-off-by: Dan Carpenter Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/usb/go7007/s2250-board.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/go7007/s2250-board.c b/drivers/media/usb/go7007/s2250-board.c index 1466db150d82..625e77f4dbd2 100644 --- a/drivers/media/usb/go7007/s2250-board.c +++ b/drivers/media/usb/go7007/s2250-board.c @@ -512,6 +512,7 @@ static int s2250_probe(struct i2c_client *client, u8 *data; struct go7007 *go = i2c_get_adapdata(adapter); struct go7007_usb *usb = go->hpi_context; + int err = -EIO; audio = i2c_new_dummy(adapter, TLV320_ADDRESS >> 1); if (audio == NULL) @@ -540,11 +541,8 @@ static int s2250_probe(struct i2c_client *client, V4L2_CID_HUE, -512, 511, 1, 0); sd->ctrl_handler = &state->hdl; if (state->hdl.error) { - int err = state->hdl.error; - - v4l2_ctrl_handler_free(&state->hdl); - kfree(state); - return err; + err = state->hdl.error; + goto fail; } state->std = V4L2_STD_NTSC; @@ -608,7 +606,7 @@ static int s2250_probe(struct i2c_client *client, i2c_unregister_device(audio); v4l2_ctrl_handler_free(&state->hdl); kfree(state); - return -EIO; + return err; } static int s2250_remove(struct i2c_client *client) -- 2.34.1