Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2557072lqp; Mon, 25 Mar 2024 02:30:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuPmpw18gIzjtRharmQk7pzF4oruCH4T5uVpPjWCBc71+MNJuwpAhq4GxC7K5yL/03u+A3GzZKXrPi+x3mqMbaFwKbaN8L9dDEej/XQw== X-Google-Smtp-Source: AGHT+IHbyA8A1bXe2tiokHYXYgXsNutheBwe2a6b4AmT0HUlmgeC/IvyMkubblg6Uuhj2XLDoz8h X-Received: by 2002:a9d:65d5:0:b0:6e6:c6f8:7c5f with SMTP id z21-20020a9d65d5000000b006e6c6f87c5fmr6121556oth.35.1711359048071; Mon, 25 Mar 2024 02:30:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711359048; cv=pass; d=google.com; s=arc-20160816; b=v0h+N5k0fyk2zCjyX2CM9gESgjTZUnNns2+IvC0EwUm1ctdx0gTC0BD+R65biZ8yTs RA8c1GSmTEGan9JBaEmps2NQ0kUqPiM1PVNst495zo3j7OxbF5+si/fAoUVNGLDz6/w2 Hig9iv1juWm8RsB9qYVcB3CXolVBeuDo+pLVeNm2zg2/8ZQ1sRVp6hbJT3ppNBWFDCxE NvOyxb3eyCrZhmttFFSWfNCB3LvdtzzYhqwcbCF/FkXgGVWRs/1XwJV66EPXNVkstTVQ gQPhXilXHUookjlQlpnXDETRlh+5kh9d4ZgMLq04o7frdy20qAQFRPMD2t09ikAs9xyi SJDA== 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=T+t+VooFQ7OquL+6mK9rzSW7lKr/zS7xjAI+V5pm6TY=; fh=vmG0dG0DZT6jWf9zcuMJh9AJpWkzqGsQQMg4+lHc/TM=; b=VxQgiYDLOdXWEKzXII8uftWFimJDEtV8Cr8Z+Zly1XjBTorqrN5j4VrS/zFeiXQo9N UgU/r4vWxGKOPz7y8JyLQyvoypf8JGWVeZqfGrFIbKa5Nl+4/CAfCQwXkkCp3UNMqGvR mQ4PfZfVasJLNXGgzFdusbOpwVI8k6W3Qh4rfKY3FbLg+HNao92XdDTJh7M0ZKGMHtd0 WsXtnER3wNphnon1Iz+BCX9e4wdH1tLZJgl4g8y2vYaHHZc+rwjHZPY9ywzZ6vHf71Wd HeAlOf+umao+2nmyXiMe37Rzsou5lO0KtLTow4fS6D6flsMZOwM6caH5nu+TTbsYsjk7 tYvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TKosLWJZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116195-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116195-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. [147.75.48.161]) by mx.google.com with ESMTPS id d188-20020a6336c5000000b005dc952f426asi7251530pga.850.2024.03.25.02.30.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:30:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116195-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TKosLWJZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116195-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116195-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 0C694B2B760 for ; Mon, 25 Mar 2024 08:35:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E11753BAA6A; Mon, 25 Mar 2024 03:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TKosLWJZ" 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 F362F17C6B4; Sun, 24 Mar 2024 23:43:16 +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=1711323797; cv=none; b=nqoR9JNRrXnqbWxsqXDTAJScHG4iFEoMfMc+lfj+67ac/kVrxWLQf5GyqhUChLZvjpv7/bwMh0BHRYBHvIMCt0zmPH4OAqnzV3DS0Nr4ooXA2ofmkMqlWtWnAQDmVTheEqklYxIgusejqDYUPi4ppLG8wjphvKdimoY1HvD8Bq4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323797; c=relaxed/simple; bh=X1cmmr4RfhomyDJsZCk6Jfrkx98hI1Q3e6kuxotVY7k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QsqXqquORCNg/mfHlZwyNpEWQIDAxdfjJaAo9JDbqAnm+Rh7Tx84CktyN5cgUaDQk82K51TEmKjBbKPMcnVcbL4AkVlCtEm7m7w6GKtlR6dbdBKWVkWBEKw2xXOIHuCQBEUc626KXlrRg+zaqVUi+2v3tyK0yBW9FCNywURdoxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TKosLWJZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F723C43394; 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=1711323796; bh=X1cmmr4RfhomyDJsZCk6Jfrkx98hI1Q3e6kuxotVY7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TKosLWJZKOP15RUYm8hWFtWm7GDTepwGa64P3KPzcK4WeHl/JgT1AcrRZYnXf+IVL 8MsdijdE2S3TW9uUsQ0Y8vBFM4vHVvJ0sVzSKjRfTF7X/76q4dC6JroI/XZcEvUClC phT7lBBJko+I9AoNOSGKNlVVNsciyiaBMvpwFN8zHBD9Y8JqC0rWfl6NixzqNqfRCD GAr50A6Dc70d04NX5tzYH17N4DfWuhfpiXekj3AvRa3sgVU54ARMCV6zMkNKLmPnLN OoaesJZbBEc86BuKSgRxrQw0VbgteiAfi8mT6XVCpOQk98+lZM4ISs8kSBC4/wymSz tXpADwP2DsCew== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Hans Verkuil , Sasha Levin Subject: [PATCH 5.10 174/238] media: go7007: fix a memleak in go7007_load_encoder Date: Sun, 24 Mar 2024 19:39:22 -0400 Message-ID: <20240324234027.1354210-175-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 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 6650eab913d81..3c66542ce284a 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