Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2395193lqp; Sun, 24 Mar 2024 17:36:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYFmyegI/l8bkgwlIag0uPX8avZ2G2106WQGAhw2CbsYYKhAllIAnbzZ8m5ojb3KBoQbxUCw7iVr60Bn24OThIbhkVm3KURExqqWOd2w== X-Google-Smtp-Source: AGHT+IGzxe6s2bvh96V4yrQZYpKcXCw4OAJQ7K7FS6VrIlmbR4oikkIxyDuoCwACmvsg4x8tSbSr X-Received: by 2002:a05:6358:2618:b0:17e:bbdb:acbe with SMTP id l24-20020a056358261800b0017ebbdbacbemr6484531rwc.14.1711326967160; Sun, 24 Mar 2024 17:36:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711326967; cv=pass; d=google.com; s=arc-20160816; b=wsxVb2iAIZ6oYXUJtHESGg0G0I0LEAMbBh5X8HemmZ9uW6qdseU9RPKutpggGF7il3 OyF6Wzto2DlbW3OxGKJqcNAdCFtxtJTdZEfhvW9Qvc8DWn7RPDMPZ0tlyMos3nlRlVrF LUFt5UcqzkqlHgW2wJ3hGmMo++LEZWotMexCXKbRqEX4XEsH/Kl4/AeNdoOiKLWyPHxq sGK1gqELyVebpRWkSvL/3Qtc97gduLqF+O0x5EvQaEEglL0lImNxWwgtQ7hLgKkbZ7Tz 0pZP3VrHgEE55+U7nNojfM6xWti4cvcSOsQ8DrLWcxGD42auaJEIjiK/AVE6jErBMzZd E0XQ== 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=PMLbnWiSi1pWi50Pv09Nl9zlbfEk3vOnnf75GbS44G0=; fh=vmG0dG0DZT6jWf9zcuMJh9AJpWkzqGsQQMg4+lHc/TM=; b=hna0Fa2mzYHzQVH2RjUqsjOGv/aDIryM0aVZ5gT+KWfdYywtRm1sQL7wr2y9EI+HFR VFkQsRCZlYltkq/o7tsPcgv1GdH5o4f0bvYb8TwuGWHPy1k8bQY9APp/neaTJPKnblt2 D8FyYMAp50YBXLEWx9ivaPFt/GyfrKBQHfPSiQ6zF1/oNvrXBFWKt9T0WPpLJCLTYSrp gMzP9p/0lZf+hkI0xCOwbR+5LQHUqSbCLZSrb1olsNO8/eKgOxzGdePapF0PwDjY6T/J Sp05AzGQatx7gigVGFMyGBvKBCGebsYQcUJ2lqJ6bzAFKp3/Cglp+khZh7EyNkHiASNQ VL1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QLlcXKWp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113382-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 t3-20020a63eb03000000b005e857e4cc0bsi6609472pgh.483.2024.03.24.17.36.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113382-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=QLlcXKWp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113382-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 2BBC1B24B5F for ; Mon, 25 Mar 2024 00:23:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 868A61A0AE0; Sun, 24 Mar 2024 22:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QLlcXKWp" 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 8C7051A03CF; Sun, 24 Mar 2024 22:43:03 +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=1711320183; cv=none; b=kEBu+0PzOP/4XwC+39ccVtV85GxKtk1VZgt4AztaEZhYJPdtcC9xZ3ChTdjoioynAEg9MQa+uKNGMSGIkQL03NQ/+uSoNr0kGP7M4BG5InOHiJo598bZKKzBisSQKTkpn5unapRwlXE8EHe+nPpe9kB1FOs9bEyNeij1Zp39e7s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320183; c=relaxed/simple; bh=TLyEqfyntQ6dgjomKdKwyWv+EdNOs2VIapsu7gTdO5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PPYWg3AL8LTeCdPbwOmUhu8SC6e2NS/sK/q0LsCQIb6nUxLMYmeG/IpCipax380auZUlNrd8ymbbs2Kgq0Sxm0qAbQuMIwcQXDhmaWywpVfbKmkiMyQMUfi2t9CZ5ApmCgqfyGIh47gnvw6U6gn/8aXq5LZ2Jq3TFcAO6/FEhEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QLlcXKWp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFBF0C433C7; Sun, 24 Mar 2024 22:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320183; bh=TLyEqfyntQ6dgjomKdKwyWv+EdNOs2VIapsu7gTdO5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QLlcXKWpfnSvjS4wfInjBG6jYYmvB+dcJKHCl2/SiFYc9XfY2zf81LWZfFuhyLdws xbtVZN/ejlrQIYh2zKFc6dHuVq31KZyEWhNzqvAJ+fLuzpsLh2y++nXCxkfQZWOLz+ 9Aa9JO4o8aMseeHJcxZ3MFpfqQlUP7KTjm7bjF58XfwI6zONBsI+hnOvJNFtT3a9iO 2RgNCrSfhnRmOpiuJxecAR3F7O/LXprxhH0y1kFCFqWoug1LqJve0J4CZV3TYzqZdg Bzxs0gs/ig9TjVKPKVa9lL4wo3BtptDB6aNNckfuZYpzVhI5az4JUhx8+Kyx5iqmW7 bIEOzzu0k6rng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Hans Verkuil , Sasha Levin Subject: [PATCH 6.8 491/715] media: go7007: fix a memleak in go7007_load_encoder Date: Sun, 24 Mar 2024 18:31:10 -0400 Message-ID: <20240324223455.1342824-492-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 b9b683844b01d171a72b9c0419a2d760d946ee12 ] In go7007_load_encoder, bounce(i.e. go->boot_fw), is allocated without a deallocation thereafter. After the following call chain: saa7134_go7007_init |-> go7007_boot_encoder |-> go7007_load_encoder |-> kfree(go) go is freed and thus bounce is leaked. Fixes: 95ef39403f89 ("[media] go7007: remember boot firmware") Signed-off-by: Zhipeng Lu Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/usb/go7007/go7007-driver.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c index 0c24e29843048..eb03f98b2ef11 100644 --- a/drivers/media/usb/go7007/go7007-driver.c +++ b/drivers/media/usb/go7007/go7007-driver.c @@ -80,7 +80,7 @@ static int go7007_load_encoder(struct go7007 *go) const struct firmware *fw_entry; char fw_name[] = "go7007/go7007fw.bin"; void *bounce; - int fw_len, rv = 0; + int fw_len; u16 intr_val, intr_data; if (go->boot_fw == NULL) { @@ -109,9 +109,11 @@ static int go7007_load_encoder(struct go7007 *go) go7007_read_interrupt(go, &intr_val, &intr_data) < 0 || (intr_val & ~0x1) != 0x5a5a) { v4l2_err(go, "error transferring firmware\n"); - rv = -1; + kfree(go->boot_fw); + go->boot_fw = NULL; + return -1; } - return rv; + return 0; } MODULE_FIRMWARE("go7007/go7007fw.bin"); -- 2.43.0