Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2490999lqp; Sun, 24 Mar 2024 23:21:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDXUJtQGZ244VQPDLbzcuijAbzxyxn0K0ut2hWbAYnLSt4iQ7YP8WUfcXKfFNcTwbwzGoMlQyAZusRR8pHJ6PBPGBphTOj9H8y3XGfLQ== X-Google-Smtp-Source: AGHT+IE1lrSbJThWOaEcdOd2jip2yX2XZeknVmCf05uIvJ0QD0DMcbwhHShJxgbT/ObzpYHV2rps X-Received: by 2002:a05:6402:50d0:b0:56c:d20:22df with SMTP id h16-20020a05640250d000b0056c0d2022dfmr1572888edb.20.1711347674961; Sun, 24 Mar 2024 23:21:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711347674; cv=pass; d=google.com; s=arc-20160816; b=UQcDc5RBnulFUivSsbkJUQEuDDjwyJNho37S5fP43tFU/s2/+OjRYcQWOqVbjD4Rd2 dt4xLWzkqUPuqSJIe/xxkJnbwMqpXcnUE3jJYWgmr3gN7G25+V6PKENRu60L9A6tQnJQ ievkD2BK7uieuU7Qrk9Dh6tdx2f7sEu14sUwQv0Xb5XMxV3a2HmBQPyRKyQeQMLWLQcJ s/PerMchWt7jFz6GgDABN+oq6Gqy2GejQIdFQ6aFjDPcbRBuQhF1W3a0XoEdKHQ24CLJ qnfW7dOS7TNcSpwQTSFfQDHtsmJtmek5e580vP9ZpxpiEky8ShQa3jREaqiQA5yfrXC+ uKEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=72fmS1CVxIIg2J3yj8DBoc0mEEQBr8tnVWdqQvkrSy4=; fh=vmG0dG0DZT6jWf9zcuMJh9AJpWkzqGsQQMg4+lHc/TM=; b=qVMUiktomEvXClDZs5JmwILyXCOC8Tn+zr3wPzaDu6xC/PixzE9+jOqY4IK1bEj9UJ sHHjEiV3NqBkRfcEZ0j7M4g8gAa0gKafH3dRATfaqCmIbX+4FxvjhcrBR9o/A2ZkBOrt doQJvfmsCsoatGF6uH7IBeYcGrIb3Ws2RB/4+gU2aJQeE1t2g7ng42JGL5QSGl4udVuo XvSZii+i9I45+hNDWlOg0cjaFDGIPL6IDL1QsTw170fe7wGni0sRrhMTNTDxo8GXX6X4 Dj8hSE7go0cPEm4MAZ4yUSuuq7/rVRB1wrx4psx33MqU8r9avPncmoRlUDqMa3beMq8g fxCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dlh060FQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f6-20020a056402354600b0056c07759d9csi1235225edd.266.2024.03.24.23.21.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 23:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dlh060FQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B92841F2D68C for ; Mon, 25 Mar 2024 06:19:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56F4129EA2D; Sun, 24 Mar 2024 23:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dlh060FQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1B6A2319D3; Sun, 24 Mar 2024 23:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322246; cv=none; b=iTar3Tii0QH6VX9PxiSJI9mpIbZBQ351AERfGIHLWcNdFpJS+ydikW5JBwlfJopWVzKWerKAZCQmtphQN+h0HvoS/SDfsbu3wemy/bDadry5I5okOFh26heylAraKRPHP9RDHrtO3IFqvkR2zpAvGeq35EwSVt57O3uMgnBri1A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322246; c=relaxed/simple; bh=lhrE8fSYga6BlgK6tHslFO927ryv1ls3v3xhZjgfFN8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R23DL28cNOriLYsia/24k1uUfidGoyV3qjyxY2mNcdABe2koI63A/C2cUMYtPYhK8FXaxxM0dnvHZiMpnJVAHsVgTCA/SxWbC9Tk6FSXtAu86ZMV0lTRk7Bi0W56Snkctt6fcEOHpzR/JczPhLn0Ronsem2Fzizd7PmJHepfNOk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dlh060FQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2E80C433C7; Sun, 24 Mar 2024 23:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322245; bh=lhrE8fSYga6BlgK6tHslFO927ryv1ls3v3xhZjgfFN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlh060FQTVDn6XNuUjT5rWxNcqaAuelawX2y8DiPleupOOZJn3M9/38DSCAAF/I0p ra5YTiqeqEsTdQ4u7GYymDbzU4cbNK1vRExNsk506pEP/gJ2Ci54WbeQhtC5qN5ZE4 E4be5An8+W0Q3HAeHO2pjPZfZjQKCJon3GwLdhS9LH8vFVAwzK2xeMyePFVkZV8W5L l/61GrD5fBsbC1S1rWm6JlusNtIN6shK6xPBfZfNNx/CGoHQU1KDmsGWwgkw55Ld66 8TZLCbz2pAR1EYm8Ql3483krPwhNya8xhDYBT6ytQ40y85SFOOSFjiODstSykvtO4Y HP4d1RoskiWxg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Hans Verkuil , Sasha Levin Subject: [PATCH 6.1 327/451] media: ttpci: fix two memleaks in budget_av_attach Date: Sun, 24 Mar 2024 19:10:03 -0400 Message-ID: <20240324231207.1351418-328-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Zhipeng Lu [ Upstream commit d0b07f712bf61e1a3cf23c87c663791c42e50837 ] When saa7146_register_device and saa7146_vv_init fails, budget_av_attach should free the resources it allocates, like the error-handling of ttpci_budget_init does. Besides, there are two fixme comment refers to such deallocations. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Zhipeng Lu Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- .../staging/media/deprecated/saa7146/ttpci/budget-av.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/deprecated/saa7146/ttpci/budget-av.c b/drivers/staging/media/deprecated/saa7146/ttpci/budget-av.c index 0c61a2dec2211..81fc4835679f3 100644 --- a/drivers/staging/media/deprecated/saa7146/ttpci/budget-av.c +++ b/drivers/staging/media/deprecated/saa7146/ttpci/budget-av.c @@ -1462,7 +1462,8 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio budget_av->has_saa7113 = 1; err = saa7146_vv_init(dev, &vv_data); if (err != 0) { - /* fixme: proper cleanup here */ + ttpci_budget_deinit(&budget_av->budget); + kfree(budget_av); ERR("cannot init vv subsystem\n"); return err; } @@ -1471,9 +1472,10 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio vv_data.vid_ops.vidioc_s_input = vidioc_s_input; if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_VIDEO))) { - /* fixme: proper cleanup here */ - ERR("cannot register capture v4l2 device\n"); saa7146_vv_release(dev); + ttpci_budget_deinit(&budget_av->budget); + kfree(budget_av); + ERR("cannot register capture v4l2 device\n"); return err; } -- 2.43.0