Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2287615rdb; Mon, 5 Feb 2024 01:31:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3NIyrx0y92sLWxXDt5x+CvJlxiY46UvW3xXvhGuSjWeTI8Adv3oBd6qqnrzvOmwfQpwms X-Received: by 2002:a17:902:a3c3:b0:1d9:42fa:c238 with SMTP id q3-20020a170902a3c300b001d942fac238mr11393397plb.14.1707125489770; Mon, 05 Feb 2024 01:31:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707125489; cv=pass; d=google.com; s=arc-20160816; b=hFaCm+11skpjpHP/EUQBZ21jpYFcMioUBmhr+vDFLBckho2BATGa0RyeTwgcJndYsy tZFn7ephqNy0GRm1jY9hPlZlBpk9mLU6oo6V9bPxotB1QaJiFnTyZHkuYkKLvjYyvLQv L7R8NHNKojy8B/MCOPIh6KNHm5QIFVVlaYakGCCMJ1hXr4kxNhrMm+OYZ16D8NitJGog 6qZWQiDkzWoCxgfv6+CQkfA53FbUhB//kG6jVHFGOnE9jZErY/rSFsjHGe/7TI8N8SkS f8qvNaRZnHk0yCcq+ZCo5GzoisErH0HlhMetjV0g5sEjsje4f7kWTu5oQ44++xR4bG2X jOhQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=xkvx1w0oc7ASzJi4InpjWhyD0+FAQfOKhn9Ds3fnBcc=; fh=7Xob2AuBkhx+TtLCFUVdWw+HCM+wJqhqNJX/h+MOT1Y=; b=dQF8ehZPlhqOISJbxvs26vXZb20FyMAGkkGK53gjsCyM/SYT6eAW78ybPU8odkhmO0 Y5hm2yUiwzWE0+r7JyxR9p4km8XDdYrtrXEYDbyuB3XyHE+zsoe1CWh/xUagwFcas929 umESHeJdNPZ/Hwre+rnTFpGbAnPiblk8lapq7u6SiPua1mo2IAEVeTazf/vnDRIs1Tuk lyAflrF9Kxd/1vF23kZwYXGPJ6sJkOW2l37YdL6liJpwX96ErB1yRPOTISQRXgo9NxAm tS/L9vLUkJN+g5NUfFPC2Ew7nPrkXEJB7g6kNE528KeHkMxQC0laYxxa8sZfgpGdYzjY TXQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-52294-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl X-Forwarded-Encrypted: i=1; AJvYcCVqygosmOEiSZH3FLq34S6D9m4ZY/gyf1PxLNwsYJ4A+02oajnpfOdWkPQGy69VyVikvnpQK2YcnYZfn64LezgO3RT/rAJABXVgSxX8PQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id iw11-20020a170903044b00b001d8f0174884si5991639plb.180.2024.02.05.01.31.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:31:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52294-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-52294-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl 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 16B83B22666 for ; Mon, 5 Feb 2024 09:26:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D7B612B84; Mon, 5 Feb 2024 09:26:31 +0000 (UTC) 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 7F63F12B6B; Mon, 5 Feb 2024 09:26:30 +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=1707125190; cv=none; b=blnPFfG5kIB109j4NJfolayMjgbfXq1ePf3ffvhW3cQLmSQSSmVl3FSqRJ/ZCbGEP1exsLldcLszc59KwyZrYf4ZgEPTrX/nv1xhHIAq0T4JF8VgyhAIaaDAp1nPztYiiFp6lGuM2VWNSpPcrOLTr5s2jdSr4fSYTxNbo7erDvI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125190; c=relaxed/simple; bh=7OyURGYGOY4oL4U5w30W7RLDOoIaRQQmTHuPg6B3DAo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=AnVg2KGMN1344omUR78MSVXuwMHemJuD0uPCjGLtJE0xVGes/4fbsH6MbNaFLU9J/knWXPdX9Niwn9VpzEGP5RMSyiceqosHHv0BFqxAIX2VuQX8IE1fa0ZDFHuupMv958QbNxqjKaN+DCWvYmYhzrFdjRbbQAUwQuTIYgIgK70= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 061A0C433F1; Mon, 5 Feb 2024 09:26:28 +0000 (UTC) Message-ID: <4d453cd8-6cee-44f1-a14a-fc5ecdea1971@xs4all.nl> Date: Mon, 5 Feb 2024 10:26:26 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] media: go7007: fix a memleak in go7007_load_encoder Content-Language: en-US, nl To: Zhipeng Lu Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240122172556.3842580-1-alexious@zju.edu.cn> From: Hans Verkuil In-Reply-To: <20240122172556.3842580-1-alexious@zju.edu.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 22/01/2024 18:25, Zhipeng Lu wrote: > 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. It doesn't look like you compiled this! drivers/media/usb/go7007/go7007-driver.c: In function 'go7007_load_encoder': drivers/media/usb/go7007/go7007-driver.c:112:17: warning: 'bounce' may be used uninitialized [-Wmaybe-uninitialized] 112 | kfree(bounce); | ^~~~~~~~~~~~~ drivers/media/usb/go7007/go7007-driver.c:82:15: note: 'bounce' was declared here 82 | void *bounce; | ^~~~~~ > > Fixes: 95ef39403f89 ("[media] go7007: remember boot firmware") > Signed-off-by: Zhipeng Lu > --- > drivers/media/usb/go7007/go7007-driver.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c > index 0c24e2984304..65d6a63068dc 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,10 @@ 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(bounce); Just do kfree(go->boot_fw). Regards, Hans > + return -1; > } > - return rv; > + return 0; > } > > MODULE_FIRMWARE("go7007/go7007fw.bin");