Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1861254rwb; Fri, 19 Aug 2022 10:36:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR62Uo8cxIumUDcQ1/Dh7J2v/CaWOpg+VV/5BvayfrGW+u4rd4ApxSYm6AgHBItnJSs6Ak5E X-Received: by 2002:a17:902:b114:b0:16e:f1e0:51da with SMTP id q20-20020a170902b11400b0016ef1e051damr8255406plr.0.1660930564133; Fri, 19 Aug 2022 10:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930564; cv=none; d=google.com; s=arc-20160816; b=Zq8t2BU0KCVYMvoVEDzKp+GXUtn96BWAdnKo5PJqWuvYswOrEOqpplXaEa4EPcUcOe GHnWHsHMhW5iuo0PfARyRJUZE2FDvaaKIDOZTtpMQjxkqqzUh40vL22a7BJ9/c6n3HMF u+rHtuwXwpaYReXb05JeIEV7kyUlJmxybNwcPKBm72Khbqehf4MaIGfLCntH1hjd119/ TZSViU9K1jVzoAGiLHKMLr3fDGm47GTT3gmItOEt2xVqDuZ70Zs41IRjEyAJ0H1K0kVZ gTS8IijCTA0GGzQwpOJh0JbRQIzw6pXkimclcrTbtyTBs66N+E7PZFWkh+EtAcJoohEX 6MAQ== 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=x6Un3/8FG6CDwiYCa7B3wllOH/iTj5CiX9zQwBaOa1k=; b=ZmhfqEe57/k3tMa1ykEPJNVR5HxEc0cKDKAQSundu72KYjV3DezfaDOG4DirnnohsT KKTJOOskL+Pl+UNz+S4F9ZPjnpHZbDq2k5TPk5ONxW9HnZE3KwsP/0KMD73/56juB7hz hcj39QKZubNhqDTUdg2jGFjXf3W+EmheRH/0rLLpWN4m1uL0DnDff6UKwN6pWLacmVGz 2XTRnB7YQopBhTXFdKOw/J4J5QYEqjOp7PHf0ufkRWUOxlpCw+YrWXWaH+GWfKodNPlN xIktwlygi+yrXhT5j7gyNWzukpLK8wMlQv4h9GEgcK1oR784cm5JglnUiWi6nnMbKhj0 TnlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OQQUVmyD; 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 f11-20020a056a00238b00b005350ea9796esi4488155pfc.165.2022.08.19.10.35.53; Fri, 19 Aug 2022 10:36:04 -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=OQQUVmyD; 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 S1351369AbiHSQLg (ORCPT + 99 others); Fri, 19 Aug 2022 12:11:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351500AbiHSQH7 (ORCPT ); Fri, 19 Aug 2022 12:07:59 -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 1E8FE10E96C; Fri, 19 Aug 2022 08:56:29 -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 8C20CB827F8; Fri, 19 Aug 2022 15:56:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9FD5C433D7; Fri, 19 Aug 2022 15:56:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924587; bh=57K/KxbzFHxWhQed+2nDPIaa4X5t6OkIrZQWpzcSoSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQQUVmyDsL7DQ+EvYFDxX31IAzoNMqLm3adGu+GG8smGPb5y9Xqj91j3VtMaMOSsf IAMmj0DrycBCObdoMexbuAx7C5qNEPzM6ahwBdWQGb0Lg5KNNSLvQ/UgoxHExsgs7l Sd9c5w+ueacXLqJCRULL2bZXPeos/WNHBzwpmbSk= 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.10 188/545] media: tw686x: Fix memory leak in tw686x_video_init Date: Fri, 19 Aug 2022 17:39:18 +0200 Message-Id: <20220819153837.775272945@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 1ced2b0ddb24..55ed8851256f 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c @@ -1283,8 +1283,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