Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3079361rwb; Mon, 15 Aug 2022 17:37:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR77VTbs36n8Rpi+FtFsj8MIx0uULy0k5Lmqh9+31Ae7FnWjiESADtX2Xi1x4U+zftqoiTWP X-Received: by 2002:a63:6b06:0:b0:41b:79cd:f364 with SMTP id g6-20020a636b06000000b0041b79cdf364mr16243396pgc.119.1660610220606; Mon, 15 Aug 2022 17:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610220; cv=none; d=google.com; s=arc-20160816; b=dEulHtGsxi/JEofbIIk86dheeww6pOVrvOX1L4UvtVbOhsCDBIAQ2xuXRmx1zE23PP 9sz1j/9FcLncZ0SETdAjL5BMGJ1pOeePk40372u6Ll+iyYwpTzmq+z3HyDC0CTcvd3gy 4geNz6tObW2Fq6eU4OlqkwnBvirDOy6SjEuQ3agd4kSLpsbOehDaYCOvv50eAI5BCXAO CRKN/R6gEfzBF56VBkiZlIGvB5/4ivjSkX/3yoCAiSSx71EzD4RdsDCkYFk6DZSTrI9z B7dLofOhJCyiS93j+4GVpGJhc6lXEVTxQVLlUYdPD3YfiHibPEoABx6z4IJa6oa3xK/Q v1wQ== 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=SaBsBOoQfNjE9PHeN4UxxGbRVlag7+2PgDYELyZ862g=; b=j1RsD0QDsXmkxYKX+T+Jf51M4lJbjaG51OVl4JC5mpaHGZ1QnZNmdPVsW7iob+4ZnL Pia2q6Aiebu2iYnpITMNYrWNPBMsF8o4cNW2004O20ce7WDIGqvmj0mR/9WLYhW3ZxRB bdWsmG+keuotFVUMJSmP3NQJP7IqNk6SqhKUK3ANlsFImIgJ02zrope0a2WDUJrfzwqp SN0Juw4sKWAvre7xvTgqXuck4PsDAynqTHY3Wc+rAV3H4EMQ5gD7PrhaiPHhglxi5+MW MGND/W7B1sKS0BHsWo3ANyVURGYsjQdhjBJzQD5PskhjTn2cS2JjwCXIGM2FUm43vUkw nKPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l3HXW8Bq; 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 z11-20020a170902cccb00b0016d2c4d1d1esi11976723ple.218.2022.08.15.17.36.49; Mon, 15 Aug 2022 17:37:00 -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=l3HXW8Bq; 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 S1354483AbiHOXsV (ORCPT + 99 others); Mon, 15 Aug 2022 19:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354216AbiHOXlj (ORCPT ); Mon, 15 Aug 2022 19:41:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70C6DE81; Mon, 15 Aug 2022 13:11:14 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2A484B80EA8; Mon, 15 Aug 2022 20:11:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A931C433D6; Mon, 15 Aug 2022 20:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594271; bh=igCe9XD8FLq279pDxbTi5slTHMaSC9V0gxCxATN22HI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l3HXW8Bqoa+h/0h7/7Zk2TmODA/AjNNTOfJ6ZZhKpsjbujXUDeO2K9U6t0kxmOvlJ 4i0NkPq6D46daBiMc4OhVzqvtSN+yNbQsXhIH6bEYZ/SKkcNvO3/blFmZda2P8cDQP sCWz9zl2qEsjc4P9aRg4bnuCTVeNOnSfPu/Y4MPA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.19 0404/1157] media: tw686x: Fix memory leak in tw686x_video_init Date: Mon, 15 Aug 2022 19:56:00 +0200 Message-Id: <20220815180455.834135546@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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: Miaoqian Lin [ Upstream commit e0b212ec9d8177d6f7c404315293f6a085d6ee42 ] video_device_alloc() allocates memory for vdev, when video_register_device() fails, it doesn't release the memory and leads to memory leak, call video_device_release() to fix this. Fixes: 704a84ccdbf1 ("[media] media: Support Intersil/Techwell TW686x-based video capture cards") Signed-off-by: Miaoqian Lin Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/tw686x/tw686x-video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c index 6344a479119f..3ebf7a2c95f0 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c @@ -1280,8 +1280,10 @@ int tw686x_video_init(struct tw686x_dev *dev) video_set_drvdata(vdev, vc); err = video_register_device(vdev, VFL_TYPE_VIDEO, -1); - if (err < 0) + if (err < 0) { + video_device_release(vdev); goto error; + } vc->num = vdev->num; } -- 2.35.1