Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp11779rdb; Mon, 22 Jan 2024 10:14:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdo3w3oat7qLrWNJdHjSDDwKX1AkC8YYGcRFJCOk99a5Rq1F90OheKdHKEaCq5TDmTSw8M X-Received: by 2002:a05:6a20:da82:b0:19a:8556:8caa with SMTP id iy2-20020a056a20da8200b0019a85568caamr2555045pzb.13.1705947275401; Mon, 22 Jan 2024 10:14:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705947275; cv=pass; d=google.com; s=arc-20160816; b=eLGMlfXkZmf0FnFN6LuoXMi0MuaXn70x3/HcvMHOeFsQsA0pw3eS0yptSAo+X+E1gC BvHAIukIejbgHLVqAKsjU8X0bAwZ+4Ih76BABdGF3RRsR40lsyNngVVaP0AbR8IFLQuS ljGFqu1cqYcqLPVGoI/LwJW6WFC1NgnQQkLp/X3JT2eRQTsJX90HSexYsLb6F/IiwJJp JHgix81woSBd9biZmnzJMoBQpxLJs7Lj8g6MMbG6Zjx4mz+VmETQMYAuvafr+1D2qw0Q FCCRwW1lewvCH8BvVPdn8xc1cp07bWD5BrgcEjw2onmm/oz3gu1qD/8NKQvK/5aH8T4K Pf0g== 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:message-id:date:subject:cc:to :from; bh=TEK02R2ZtOFeCAZjt9vWLdCyU8SmljbxGXvkl8uSDHE=; fh=LZLbbcYcsqkz+LePR5VOYOpiexqz60hX4s0GtC31vHE=; b=yLvbEk9yr2g5q8Agl55L0NM0WoKniOOUBxFcAL6WTxjYiVoKfD1Mowqcd1KmF8L8zy XKXMvSjQ7qmMZ0Whn/qvWf7nwiMzDLhVFvt1OsrTr5VjBHb8LBd0H7hrr1wSyE2W9x4B nhM0zordqMbKLWYaij6iCktS0fes/rKFmLGx90dQIGu7aLr4pXI/sG1xNCQd5WfB+eSS yP/OVAXOayhZPfFO0Tr1/H8RttlLEvzdZ4SO5YsKrJecd/1Zf5SdwMKVNbGdtX7952H3 YoHBpVty0e44rB3wBuM2iE7RRq2s1PWqtVbB1GcvmTBYe9itaRwFqB4eyXWNwQf/MSJE UC0A== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-33815-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33815-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d15-20020a17090ad98f00b00290bc2e64c8si731493pjv.138.2024.01.22.10.14.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:14:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33815-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-33815-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33815-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2B3C6291890 for ; Mon, 22 Jan 2024 18:05:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B03064A89; Mon, 22 Jan 2024 17:26:49 +0000 (UTC) Received: from zg8tndyumtaxlji0oc4xnzya.icoremail.net (zg8tndyumtaxlji0oc4xnzya.icoremail.net [46.101.248.176]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C04963500; Mon, 22 Jan 2024 17:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.101.248.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944408; cv=none; b=VYuTFnZASntdiHm70ll5ONiCAn4ScUbbhEujLGefvc5QztcTg4QPf1DmuauJ32JMRUm06VS7Y3VuVA9kJ+kTSsDcQU8egZppe1+t1s9s4ituqALzFR0o5h/9ZUAay0pMn5k6Qpw3LD5dqpfEuMKRcUsLENEeO2uDmyrs0gsqBc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944408; c=relaxed/simple; bh=rL/0SMt1W90GcdnJIhIcIHzZB/uqhXmkYCEKtnqY1l4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=KWBiPxKO+ydKw+lXCtHU9CLIiYCFeWm1I3gt3tPv2JIN9g2W5fguGlTTixJvGnrvmxo35alaOewQwNZxzpKY+0ZPXf4VTSvwZHx0eR2YCZ1yP5BnDWNvFXrafNZ1gMzfrnTEvwNtFRuiRbrLGbSl3SeXf6NFaCFEVAwRYnGKb3E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=46.101.248.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from luzhipeng.223.5.5.5 (unknown [39.174.92.167]) by mail-app4 (Coremail) with SMTP id cS_KCgDHwX9Ipa5lmGV5AA--.39403S2; Tue, 23 Jan 2024 01:26:33 +0800 (CST) From: Zhipeng Lu To: alexious@zju.edu.cn Cc: Hans Verkuil , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: go7007: fix a memleak in go7007_load_encoder Date: Tue, 23 Jan 2024 01:25:56 +0800 Message-Id: <20240122172556.3842580-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cS_KCgDHwX9Ipa5lmGV5AA--.39403S2 X-Coremail-Antispam: 1UD129KBjvJXoW7CFykKrWDXw1rKrWDGry5XFb_yoW8Gry8pa yUGFyUAry5Kr4Ygan7Ww1DKa90ka95Cay2k3s3Zw4fZr15tFWqg3y0vFyjgr12ka12gw1S yF1DZr17CF45ZF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvm14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26r xl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v2 6r126r1DMxkIecxEwVAFwVW8MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r 4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF 67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2I x0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnU UI43ZEXa7VUUTq2tUUUUU== X-CM-SenderInfo: qrsrjiarszq6lmxovvfxof0/ 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 --- 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); + return -1; } - return rv; + return 0; } MODULE_FIRMWARE("go7007/go7007fw.bin"); -- 2.34.1