From patchwork Mon Jan 22 17:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhipeng Lu X-Patchwork-Id: 190334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2772283dyb; Mon, 22 Jan 2024 10:58:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8tQtNFu4B//JzskJi9x4PtQPbzwq18qrGnslvSLlUbMNjMoBUmFF/RpfQsgn+wjSQ6f3i X-Received: by 2002:a17:90b:2352:b0:290:f52:a045 with SMTP id ms18-20020a17090b235200b002900f52a045mr1513409pjb.82.1705949920940; Mon, 22 Jan 2024 10:58:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705949920; cv=pass; d=google.com; s=arc-20160816; b=PgXumdiCrxbEwjbncLl/ckPTLgX0ad7vkJQf2hkcM3SSHOm6KBtlIqAbxpqWCfFKAU svSIhfe901xjeWfx4iZjBYNFqlhilyr+uDGRwv0NA3cZkq1iBR2QLywBlknunJdeJDD3 1UhSAy9+tBRZ9aQvb+ZQ8o19+/k6Ti/m4V0NC8zSiBiOnB8NsFtRONoL2kiLMBXGyosD liQfSBFvvWEyudC3aR1HT7eDBYvm4dtIU/PIi4WkfBijjbfStD6RgZG8plX9udPk7JuP V20A5VvJUtfY9TKPM1EefTkHhnB2Xj0yf14xW5DM8n0uC3BOE2OJVQKGPEPlh7gaMssk 05jQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33815-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h11-20020a17090a130b00b0029045145b93si6668252pja.40.2024.01.22.10.58.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:58:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33815-ouuuleilei=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; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-33815-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33815-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E0324B2ABA1 for ; Mon, 22 Jan 2024 18:05:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B26664CC3; Mon, 22 Jan 2024 17:26:50 +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 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/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788818144162368185 X-GMAIL-MSGID: 1788818144162368185 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");