Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3017849rwb; Mon, 15 Aug 2022 16:14:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR5WTCPQVw8IGUDKQpxEN/GBAOiHANC2nAqU/cn3IjIYTUBfzkeAZfm1CVo3t9AwgLR2qEv6 X-Received: by 2002:a05:6402:1bcf:b0:443:1c7:cd07 with SMTP id ch15-20020a0564021bcf00b0044301c7cd07mr16784946edb.365.1660605272002; Mon, 15 Aug 2022 16:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605271; cv=none; d=google.com; s=arc-20160816; b=f6bqCmbnAonCdpB99lARRVxn7YjcJFxJ9TKiP62sv3281jc8BicGAZNHkm0pvtX2BJ ux5f6YWKS/hcx/qeAw97Ln7Rr0S2jnxupT3MSBWvfRDRTFAK0Yq4/c/zPVA6VXRN7v/l fS9KmS042a3iZGN2HEizvssxQ4cOUKkxgDxtC5Fs5YAOMeEb+gdWfzbzZ28JurMAs3dO QG1TZA36HlQqm4V6JxVCAeFFvBkQZ85kae8fBJB+k0N/5iTLC7a4YiTNsDRClSpBzZ7t dP/L1QQnon/B8rQL7lZ4Jrk4E80eOycZPAxOMvUGqOdkt6JhMWFLH1UsoIwTbmDdHKpL pkRg== 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=stEksuT7GrqgZWvZQm7z9p8Gq7UHCtGAvynrbeD03liTe2C6b97IGYDJAtVF7GmuTJ xZtSQ6Q8sAB7fHRCmr/W5uVVzeQsykiclsH/4lDU9b0eF3AvxGV9W6KeFqRwyA0053AY ECECThn2Xm9y8nVNywxMdodKWrOjycEE+VWOCKMtixHIJW8EfNCmkTE4kWnEmJWW8UD2 lImG0AfH5LMX9yEBPhiEwEAo4MxUpr5QpF/clsXT1sVaqW22rVfDmn7WilUHNLRYKPWn uAE2TM+rUO9esFLQpYzalj1HR0zV3SopAQl19FteSCbUwNgQfr0J6eESbd61zZ7OzBSW vgHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VyEJImBZ; 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 sb35-20020a1709076da300b007330bee74cdsi8744177ejc.676.2022.08.15.16.14.07; Mon, 15 Aug 2022 16:14:31 -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=VyEJImBZ; 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 S1344924AbiHOVD4 (ORCPT + 99 others); Mon, 15 Aug 2022 17:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347259AbiHOVBk (ORCPT ); Mon, 15 Aug 2022 17:01:40 -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 6887EC990F; Mon, 15 Aug 2022 12:13:43 -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 A6833B81113; Mon, 15 Aug 2022 19:13:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 024AEC433D6; Mon, 15 Aug 2022 19:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590820; bh=zkcR0TpSskPaMHhtJO8TQPX3DUVVd6bVpF2lpjf73/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VyEJImBZ/wEtn3I7u+upwV29PMN7r5gUp/CDvW8h6WXrI62aie4fTlaBdnZi8QPKs 0K42G0A+D3QzL4cOQfoTyTUfhRe1BmFoHWeWe6wd/cZ1HmT6XU1KdNotliwilBoeTy v8n/U8FuFbI6S4bdmYE5zAZFhJEEP/TuiaSSgX5A= 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.18 0381/1095] media: tw686x: Fix memory leak in tw686x_video_init Date: Mon, 15 Aug 2022 19:56:20 +0200 Message-Id: <20220815180445.446492358@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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