Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2920031rwb; Mon, 15 Aug 2022 14:04:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR5/nm6iHQJ3P25IlbrtMsGyPI21ePjCvqH6SFZzroStHRU1YwyXD033K/eHxuNf7jmlHKCP X-Received: by 2002:a05:6402:4511:b0:43b:a182:8a0a with SMTP id ez17-20020a056402451100b0043ba1828a0amr16014852edb.410.1660597464840; Mon, 15 Aug 2022 14:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597464; cv=none; d=google.com; s=arc-20160816; b=OIPUOvr9hXpPOLXkMSAN2eW6ov/kuoeSver0zAL7Q+Q4Cm9yFUAK6RDu6B05AnysAv oXpLCSIVEFLhvcILNJOJ1JvLJ55ffS31p9q7LnA7S6PpgfENpfFr16CeoWeopjxOjQRx yiLzJwXAs41ZCs0ZpVE5P9vsbROFKTlC5jUDdXh231IMzL79tBMHG1DJIfGQmRYSGEMz +8ENIKhM6IrZe+AshChVu4gxFoRfqTVlYLppHbjp/pmxoUC31n+rjtfevuuAiusdIS7D ZsADdi6UZyUn7UwxUhs71ytZeG1DkLfc3ATC/bdSb46Dnvc9LALBcG8cxZsa2axpBf2I QFDA== 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=P7NhCXml2ThwLV2tA5PYHiWNPOy7mIWEXVdPp5cuwzA=; b=nAOm3L2P5SyupxmW7fOaVnKPm48YnR7dDI512+tDbYGWGUqGjnHIPGdEfJ31ezwwWd Qd2LUlBVXmwz+qHerCJ6tAlp6jr9dWzNicL+M8XAOraRloyT07wMwl2TTANuyiHHsBlT futjzAgottWDQojwdW13du1k8vJ8ckh63NC7auisI7cTYNWPjcO0CzJNoDBDmInU9TcI KnmofmNHCkxhIJvqE8vHGzcWXUzPnZ1xEn0npgz9LYrlS9Mn6Y5MRmaMhzGzjrP2fjyq MiV65XrK14BHkq3DC3ioy760FGqwVtIpW85Ur2SYXN8nXaZjTE69VsOCStO0Lg/QG529 RHKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nA7hPClV; 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 gb3-20020a170907960300b0073074f58530si9550454ejc.877.2022.08.15.14.03.59; Mon, 15 Aug 2022 14:04:24 -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=nA7hPClV; 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 S238924AbiHOS5b (ORCPT + 99 others); Mon, 15 Aug 2022 14:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244305AbiHOSxH (ORCPT ); Mon, 15 Aug 2022 14:53:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8DF8481DA; Mon, 15 Aug 2022 11:29:57 -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 0EBA3B8106C; Mon, 15 Aug 2022 18:29:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F718C433C1; Mon, 15 Aug 2022 18:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588194; bh=zkcR0TpSskPaMHhtJO8TQPX3DUVVd6bVpF2lpjf73/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nA7hPClVV4OYTFPn/mK5J+f/CzrXwhEV0AQBBHpxu/RZ0HeEm17Cr37FC1KIJl81A QJW7RWJbLwJgiQpUozMPyoYgB7/y6Od9HEKWmad7c8cffLwpg9akEXjd9lM7G9Ri0k f38k66+Fakd2HBi2TrqcrmZI5RxbIRcbaFq+ZnF4= 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.15 293/779] media: tw686x: Fix memory leak in tw686x_video_init Date: Mon, 15 Aug 2022 19:58:57 +0200 Message-Id: <20220815180349.810320432@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 b227e9e78ebd..37a20fe24241 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c @@ -1282,8 +1282,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