Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2383441lqp; Sun, 24 Mar 2024 17:01:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUW4pAaJ+Ue3TSK9iMaJx6aLiUmWYRdwg642Xnjv63WUB873FfIyRANT54n0UzHlydblkMy/eHn/qVpW4hGCCUdhIGyal6LVx2GT9BvlA== X-Google-Smtp-Source: AGHT+IEqh3QPe89P1mfx2wTONu0jEED84BP2B/rm//+V7bIhgQ2ZhWuR8pf/1MJ2umxOrVPFl2R8 X-Received: by 2002:a50:8ac6:0:b0:568:a226:6685 with SMTP id k6-20020a508ac6000000b00568a2266685mr4516162edk.8.1711324897581; Sun, 24 Mar 2024 17:01:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324897; cv=pass; d=google.com; s=arc-20160816; b=NKtR7uRFJeHeItsNCPBXt7YCdQf9N+dLn67/4dQuL1MbCMvcJt2uPK3fMwqId/Oq70 pavYGY0+OILtE9GbLsOIWH8BZ7gFXtBt7UWjIlTtUAcD8VsYiOA7h6LZHhdlypFalEPx Yugy/b0Lj8lr/+wH+0yn1+N/GbJ1lG4aCqnPB31+Z39Y42gU9D5NTMkM1SI33boz3E1o lqGhxtGyxUxh27f9bZOtKW2rdLalnKrweOWhTDwI4zHo7qjYQ04JMXe5OLGjyJRV/FvE VBIKqluMrjIwWMhfdUeEa3SkrnbnG3ac25byyi/2qqujubdIYHMayWpGyGHbG2ukFFkS XESw== 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=EFda9okqsUXmR05LcrQwhYHHx3eSHYSnHAY6EX0lmjw=; fh=vmG0dG0DZT6jWf9zcuMJh9AJpWkzqGsQQMg4+lHc/TM=; b=fXycXvuuTgg1H+0H2LLrGiZhORsr7tyhScNVfyLHbYm1YvoDcbaay81T/G/3FRXn1w vRM5mRwGkODLi5rnnwJjRp6seXe55Z8MnLuRYRJqT+WbED3H1uU9glM3AwsaCB7/IID9 r5mJ1AHmYkEWUVwA2Vx7KFvfkByzGwOF01Y/obQUJF7xXhviBmr8BLvpPEiEoKFvPgJK oZwLPdNlkezfQEZTJgKrj2edadnTvxe2eJ93Zs9g4ddLDbiQ8e5Y+RS/A9wBH44U+Tks orFZBQfiQyKGTo/6SMPECBOWH23347jC5ErZYG27shfwDqPcZm5oSgINsi44w8OWUhHv PPqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CQX4ijUv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113287-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113287-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b14-20020a056402350e00b0056bfb83ad6asi1624555edd.2.2024.03.24.17.01.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:01:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113287-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CQX4ijUv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113287-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113287-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 537951F2635C for ; Mon, 25 Mar 2024 00:01:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D58618E0D5; Sun, 24 Mar 2024 22:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CQX4ijUv" 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 250486BB51; Sun, 24 Mar 2024 22:41:27 +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=1711320088; cv=none; b=E3JuI49N3pWWFXbDHc61iaVCVKpci9CwowbPBuija+sUkEazoKtxtcepGx18+qX1x3fVfvwTXlkvSuBkmZxm9Asqr1JBOimwPIymGYMeQBhDzptla3x5MPPx+okJOEL6QZisUTYQ32K1gsaOR0wa/siDCcK8GOkj/xTlA5H4BNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320088; c=relaxed/simple; bh=d6lzkkIjVC8j7FCAyLRzMX5ir2uPOxbS8UYQkWRwhlM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y46QL5DDgxmWWhCYYvoM8Xcmo/jtEDcf2CcVwu5vDp0Ekzk3SpXQmlkfCNPX0uO+4534VbddlmYj5KzE5TsXGdOtAMtpCKO5K+WCY00Z6ytB7q2taMN9vZvTthXAes6AIye2EvVvYshpQ0bw4oioSwrVG/7Lh0zrlSx8pPLOlNY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CQX4ijUv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D144C433C7; Sun, 24 Mar 2024 22:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320087; bh=d6lzkkIjVC8j7FCAyLRzMX5ir2uPOxbS8UYQkWRwhlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQX4ijUvkMl/CYFB9Pg2IhrXEc57kxKfvrti/osl2DMGDWjM+MoFVtRccNZ346WHi EYUY0t4nybEDaiVnYbMOZaXdOVeEYUEz1tQK1LIs6P3dJcOliX5Trgpghbsf4ooxag 3EghFDi2DLCZSQhCYGiWpcuB1hYOS9+f79cd0Pqe1P6VxiMiuyZ27PLppYNyN5+alk 9AAE6jJ65YhXMOMFIa1JkxfiLTIOojIo4Zo1XxgMG4ti9xAezREvWxCb/nvw26MAnH 8ZWH01JnuKIpY3hEfgnrw1L9C+Kd2PxaaUcV8p+YiIX5AjMwKk5ARu7vt+1stDB8cd T4baoQ8wjyZSA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Hans Verkuil , Sasha Levin Subject: [PATCH 6.8 396/715] media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity Date: Sun, 24 Mar 2024 18:29:35 -0400 Message-ID: <20240324223455.1342824-397-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 9e983176542be..75517134a5e94 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -1087,11 +1087,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