From mboxrd@z Thu Jan 1 00:00:00 1970 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 D078E17C6C2; Sun, 24 Mar 2024 23:43:17 +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=1711323798; cv=none; b=a45M3NAeUITZsRWZaG8p/RvQ7yAEFBoS9GXr+zeOQNmV4f5JhkvERe+jw4gISEYmvmUr4XMPKuDPQxbgCIlnr26ej9TEKiGAQwjRk3WfwvY45AmJ8EAD08UPCjVCgabvgzyearTjBTBx1JHJ7w6QCMy2l393l+yfDPRbRkddUwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323798; c=relaxed/simple; bh=ieKy/hv6bciQ6MqgyuqOGf6/YtMkhtBG+HDbPucQycQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q5iwcbF6+HQCLQ0qkL+GFGWysrGNd2c87Ch5DySG51m37LNwK8EBOueSMZS8eBJo946t6WoOHhZGFxihVhisYPPC1YgpiZgEbd+GgqiSE0pBfvh3cSJwNDt2Iigg4cM1Axco2UqXpZ5tL5uX6eE5PzuHj9WPcpdDSpuEoJOhmiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QhxQwSEY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QhxQwSEY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 139CBC433F1; Sun, 24 Mar 2024 23:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323797; bh=ieKy/hv6bciQ6MqgyuqOGf6/YtMkhtBG+HDbPucQycQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QhxQwSEYrDeYpujnPH+nghySXbicHHjj8Yo41GgUYXnfhgBQTtI/sZmx/wQCDjJ75 zeV4BYFNTm25XuVaRjbPFjpnAi3CRp3Go+qPjFXw+UO+fpqXG006mBdkF9NieTMZmK BWc/OJcPMToCZga9eC7ZLO8rygKSqJ0j/zsEoXlABrdfg404YhKQgJiYxfRcezHmta 8QpfiLIvt0FuJBKuIehmcSydtpa/Z1rkz+ABAf5hn/weZxpi6hI9x/FQoqfMKxPstz kMSmj9oqJPrlTg253+VpQ32YSOZeMZyWF2TZ7aPA141ht+/ZUoRTN7XIacCBU2AGlc ddsO6wlx0n3Fw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Hans Verkuil , Sasha Levin Subject: [PATCH 5.10 175/238] media: ttpci: fix two memleaks in budget_av_attach Date: Sun, 24 Mar 2024 19:39:23 -0400 Message-ID: <20240324234027.1354210-176-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-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 --- drivers/media/pci/ttpci/budget-av.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c index 3cb83005cf09b..519f85e0a397d 100644 --- a/drivers/media/pci/ttpci/budget-av.c +++ b/drivers/media/pci/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