Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2625486lqp; Mon, 25 Mar 2024 05:00:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVmVUETkdZWD0WKdaLp7TZYD0xtue9Wl3+MU56XT667Zc65xdelDOle6+clF94r4E129C1ESA9hp4N/txwcCmV5OEGSBXwxXPgw3AuFg== X-Google-Smtp-Source: AGHT+IFNx+kTXg11dwdvGMf/s9v7Lw0uYTzfs5SVrZ8v5suy+/G8zutC1H0RTEUjLlFalFTwtbjb X-Received: by 2002:a05:6871:4317:b0:229:e689:7c1b with SMTP id lu23-20020a056871431700b00229e6897c1bmr8196786oab.7.1711368025715; Mon, 25 Mar 2024 05:00:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711368025; cv=pass; d=google.com; s=arc-20160816; b=X6gLP/ou0RMFKQjSeHVq3MIqH6C29PccuXOxzMrUI1+PlRM8kx8EQZWeqArLkQ+fb1 OYjbPLiYXFw/pcNrsoBH2eNxbpYzeSiH5oC4JfDPigsLuHxcdJE35d/VbQ6rnMZlBlnk U2Yq7KDEI106Gsk/ocw9CY34wVuw4guzZPQb6fZjM3R3HjkqHWA4YLbA8VszdHVWEvhG x0ApgpeQslvfetoDiBmAPEa40Lkbd+/T3zOG0MTRWmX3crF7ZW097qTHGdgL7xLuO/FE PFSoend29Lz/eIk+gV1L9wl1kXljTLEfJ6l9YMVb8keyPV6Qqu270lpUrOm6LyaFT+NY Xn6Q== 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=SKxXW7XpeKC9+XXL+/zChgvFBesOmHRSQRWlTKCSaNo=; fh=vmG0dG0DZT6jWf9zcuMJh9AJpWkzqGsQQMg4+lHc/TM=; b=u2UznYt1BdJ7QMYSPDkkGTfodMN2QsGdByC/A9IkxJICZVeGP8y5TQzPFdw8N4VD21 G4dUi03iDwlvh/C8VdpdJsnoNmCMvOxda2KDrZtnTWLZiqvQKNDx/J9dO47KUWKlNy8t jqkQCliPZs13jd1mUlfWH8pl3rbtOb7/A/jN2zRC+8AbeRH7lBeDceuCk2QYqLVoPXso 1PvA3fmKZm6a65yuJ2c8hoVCdpawZAvuaGGMeL+fmrTT8ShdF7avbsiNOV/S6AHL2q5B lir1c67TxWkw+NHVCEPwqNT/DM0bmZe/n6fpx6YAit9fR5HM1Q3s/F24GD3oCSy5cxrb jkpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AkFhEpyQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116178-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116178-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 u10-20020a63470a000000b005e42b4bb9dasi7370049pga.213.2024.03.25.05.00.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116178-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=AkFhEpyQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116178-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116178-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 821F4B42312 for ; Mon, 25 Mar 2024 10:23:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC1313B7871; Mon, 25 Mar 2024 03:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AkFhEpyQ" 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 AD17917C19E; Sun, 24 Mar 2024 23:42:39 +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=1711323759; cv=none; b=lUZblm7ApVArkYTiJnFdhUDSBv0afq7/gpZPpF09I10SQysEGNOTrVh8WM8YEmQrD8L3XflP2Nh1mXCW9aydptBRWhw7CJpL7eAJe/72kjNQLTn+s4begbjpDR6oVq4u23I8eoG37IE132NrEi2LidVC+xOoHZpJh4JsFmRdZUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323759; c=relaxed/simple; bh=lZi2nF932yfaJDHA0T9yEuil3WiBHFu4xjhRzOjRwU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AmOeGBALKhMdlVxFxRaK/1ZVFGUf99vIe5e/08kaiDYedlgKIbc5SramDyLI9f8eMHrg9+7tk2j6ihFC7TKUz/CTqtf1usOcOzfmJ7GhkYaU7sgYUiacHJDIObWTw0hYYXX7R2DzX9Vmhi7TFaHuT6uxLN8nVc16jrpJ48DrYBU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AkFhEpyQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE6EEC433F1; Sun, 24 Mar 2024 23:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323759; bh=lZi2nF932yfaJDHA0T9yEuil3WiBHFu4xjhRzOjRwU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AkFhEpyQjyvXmptwbBiY3LolvGtAUB+H+GaQBeCpNc7IM2UR6czMK8fU1DwOQhCxq jkMdj9w5+vPdhfiFZOKBhE5X1CUPphbjK0KA38IluD/eLPQAcnL4ZWlKRu0B+haLgU sz1PYf8VgQPmm/FoEi6rLE14xofwueEV6Wh3rLXUhlah0V+Ho485i3YbWwPBdMKVG+ 7Pd5+CZSBUuDev3GmjeV0EhXau52aLs3AYt+y3Z+cfbARYj5AjnGQkOJ4JPZKjgVDS MJwetYFLFtury08UXaBITIKE76IaLNIihMQmju/SOosg8icvSKYI9mTXQLH2Rl+ykO 5cmj75ePg/kGw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Hans Verkuil , Sasha Levin Subject: [PATCH 5.10 134/238] media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity Date: Sun, 24 Mar 2024 19:38:42 -0400 Message-ID: <20240324234027.1354210-135-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 8f94b49a5b5d386c038e355bef6347298aabd211 ] The entity->name (i.e. name) is allocated in v4l2_m2m_register_entity but isn't freed in its following error-handling paths. This patch adds such deallocation to prevent memleak of entity->name. Fixes: be2fff656322 ("media: add helpers for memory-to-memory media controller") Signed-off-by: Zhipeng Lu Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/v4l2-core/v4l2-mem2mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index ad14d52141067..56d320b1a1ca7 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -1053,11 +1053,17 @@ static int v4l2_m2m_register_entity(struct media_device *mdev, entity->function = function; ret = media_entity_pads_init(entity, num_pads, pads); - if (ret) + if (ret) { + kfree(entity->name); + entity->name = NULL; return ret; + } ret = media_device_register_entity(mdev, entity); - if (ret) + if (ret) { + kfree(entity->name); + entity->name = NULL; return ret; + } return 0; } -- 2.43.0