Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2395274lqp; Sun, 24 Mar 2024 17:36:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXS79QouyZOMn69qD5O3Qjzdm33KiJw80gAIaZp4ELPjhWkMG07jcRyQc/aL2HoApm0wZ2k8lPmp+Q/AG2kwNSsXrxHN/k84Zf226nm/A== X-Google-Smtp-Source: AGHT+IFa3oe8ShqhvUbTJZjUASCC7pxmTZPU8rEIqccH2pTfdbIJreei2n31mhSBW/DgrnsJ779j X-Received: by 2002:a05:6a20:8424:b0:1a3:bd98:c4af with SMTP id c36-20020a056a20842400b001a3bd98c4afmr3509082pzd.48.1711326981453; Sun, 24 Mar 2024 17:36:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711326981; cv=pass; d=google.com; s=arc-20160816; b=UW21fpvJEqk16DfyuqAJfs7pBnJZN0fpcm8KSzZqltCwKJZtuzbfcgvYeW0GZcCu4J Z4nYk1ZS1zcMXQ9v9/+xBN4K4j+ItWCkqqluVKC+Z+a1SF3C+HAcUsVvxp3j9tHOP+uD +LOTd/MvJKZ54S0IMl7wWCoW60DaCY0IFGEZX2efD7jxLMCHwEIH7zsS9LCujrYZE2q3 gRhxbI+sYZ3ojNRK9cBVN5BDJtxD/dyOLFn5SOI0QQUeBncVllqrgQWLVz9xnWwiF9Lm l6oKm6RfvOiqk/UYiE/ksuVXcjJLr03/rKVcE/DomiOryGdvtWh7Mo4gaxdOiI1l0dPm s7dQ== 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=3fGsmFrVrl3OgNu6cTiRJUm2HWZyjwSzKuO7D2f5QPQ=; fh=vmG0dG0DZT6jWf9zcuMJh9AJpWkzqGsQQMg4+lHc/TM=; b=eTuC6BdhxPyWaFvNKrabZPwK+8OgGtmMIp7FR+dncEgKajpKMC69ck6/JDRSVD4zAC JuWWKROfONF+HQahv0Q6XA36lciu4WI0LLyykTDFEaX/ACuMHNwzdDyy2xtcD7L7LAA/ Hw/pvdTMevXiBtggHnW6Zzew/SuiOwsoIvGZpdaFJWYYphFngtyvNXfELv0VDp3EFoc7 PkDFZrxS6/S5dreyeBpVPexPvuarYUn9xvPiketclCSsX9qIhuDG4UqtlPufUJrBERWx Y4iMBgeVP4abRmm/yO2EheZYQfXa93NEFgZGkuEWEJWmyv0nK5X4JJFc7taHOvIpl3eY UKIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b2IRfJNf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113383-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n9-20020a170903110900b001dcafd161f6si4042557plh.475.2024.03.24.17.36.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b2IRfJNf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113383-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 905E5B23B53 for ; Mon, 25 Mar 2024 00:23:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EB0F1A0B04; Sun, 24 Mar 2024 22:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b2IRfJNf" 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 6CB1B1A0AE6; Sun, 24 Mar 2024 22:43:04 +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=1711320184; cv=none; b=W6EtVjxhp8gHkVkXaAHyP2h2dX3JDqqf1WMCy4LbFShExsclEPEw4zgI4K30gCnbFkwj2Z0kFUYDz/+CkdB8BTBo32TG6C5n7+Xza6QPK8Dn8P+NQ+NpmBkP2Wb8BCc211x8dWNQOxN0pFf46Q+E0SPELtL8WXhDnM37Ttebbrk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320184; c=relaxed/simple; bh=bgLAqlsnttLg7kNlv60BvhVTkQQ/GGMhQj+OGhBRKN8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GQFf8TlANq474aTRNAbqv+OZp5B33GwkJdcj43tKGhRXxh33rGcmXTTxibZ8jCZVo4Y+QeciWKey0ruP6nfkvpA78Dw/nLIgtjODyX0wpqjy4RBSM4Hxj66/CgH7FR8p0ruzDMu7o3lfhPqDIHoQFiaPmivUZVSuJQJt/mqyziw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b2IRfJNf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8B3CC43390; Sun, 24 Mar 2024 22:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320184; bh=bgLAqlsnttLg7kNlv60BvhVTkQQ/GGMhQj+OGhBRKN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b2IRfJNfoCQFZzsFT424uCazjNhPsQGAE1sbM8U+HwZK3oP7zT8+KCz8ABrNaiCpV n1jatyI2TNorI5zRI2KI1WhDUHYT/ze9EViQWykurj8LRM+zZF9pV0r75Ub8zUgFwE CoOsHyPcCS9U2IUxqC3C4y1kOYCp1HNzPAIQ0w2MeYfFfoHNFY9hBr+IHVxDa/u3C3 7iiic0BUvMZszMbVHKKat+4tPxVyXDgzYmQj2yp11qy3LoDSFeFC3UnACK2n1CXNJO gdaKheQL3MdjbJw4g9d/EF5ELX6+fIKGhbGF9/9+FxBmlSna9prcq/6fqirZMsi04y v5zYWxbpPEhgg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Hans Verkuil , Sasha Levin Subject: [PATCH 6.8 492/715] media: ttpci: fix two memleaks in budget_av_attach Date: Sun, 24 Mar 2024 18:31:11 -0400 Message-ID: <20240324223455.1342824-493-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 230b104a7cdf0..a47c5850ef875 100644 --- a/drivers/media/pci/ttpci/budget-av.c +++ b/drivers/media/pci/ttpci/budget-av.c @@ -1463,7 +1463,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; } @@ -1472,9 +1473,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