Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1446609lqj; Tue, 4 Jun 2024 01:33:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/3jqLvNGTzR3jIvyFFGOkYQ/NXGAAYkNABi5MKxENcBl6O0cK+MMNISJqKaZm+BTfqCSMmgrSIbsCSBTVDlwSQs5eo+d23f+UG5qJZg== X-Google-Smtp-Source: AGHT+IE6mWmKvG4k5lqU/i4FTSyyddGuBNSNdCXlpSC5EXcnZTjyqFhh2jVtLkADkIU3HCx+W+yB X-Received: by 2002:a05:6a00:2d25:b0:6ed:2f0d:8d73 with SMTP id d2e1a72fcca58-7027fbaa4cemr2709788b3a.3.1717490030758; Tue, 04 Jun 2024 01:33:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717490030; cv=pass; d=google.com; s=arc-20160816; b=Flxlj306RIKuOe19tVB/XIjgdtlbEu8JTWZUNED/NJ5V/Ss4UqrooaYBx9ohZcB7wm YnBOYiNe8SKzlR6jeyVmPymrCmISLsZGfAIaSrDXi9kDD/EMu0oqUSzsdBhrKR+7Yyrf GhjbC3DvBBzJpSbTm6PJCFgY6Mi0TvL4QWXc34zhkWcewJuUO3tVEH+6+Nn+opdebfPn QmXWENv7BxGmbB2jF+KIZd4ntmb0xZJQLiW2H9qgQQ2yFnxQygITVAzwgRouJjk4XYTZ cw1tHZUTiErUWN9uFzHjUTDRsfAHru0KEDrZ4TOBAkmdwqtA4MH9y0J6Jj9wAbuqe/h+ PVPQ== 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:dkim-signature; bh=YeD6MfvMCDss8xIrAwzRquwsKR0GI7snBrlrIBm/Ko4=; fh=HhZMsY/bhQjK83kvAH0bOzWCn/Zg0/zDVIgHHPeorEo=; b=pU8lHjIeFyIGeT89BQnMyhrLzpRJWmoDdDYHIp5jjo0ivnb7hT66uMCr3Ew+/00fxd NAQEuHuK7PGASs2GabRwbukwJV5FM2dVlG7NHEeI5mfHZBXm/mF9SMVWzsPksY30ci5q cf3jmhjoAqwAYDsGPZTFyBEsFi7EaeFJKtN2+e0IwsNhKoDLb1y/QmobJTfgjyyI21no hyntCuabSqsqlXRa5Ov3NxiZihbGDFRGl5LZKylxrn6IVlKFYGH10cTa/zp6nL1p3Jyw gMhfrS1kJra3APo8XcQgrWCtAkKrsvzhhEWN8ugrewgWyU9allNEzYUmcKfm45GUpG8q l5YA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qZfdi1+5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 41be03b00d2f7-6c35d694980si7705414a12.836.2024.06.04.01.33.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 01:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200253-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qZfdi1+5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200253-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200253-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6440B281658 for ; Tue, 4 Jun 2024 08:33:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CA5E1428E5; Tue, 4 Jun 2024 08:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qZfdi1+5" 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 790733EA69 for ; Tue, 4 Jun 2024 08:33:44 +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=1717490024; cv=none; b=ulBgh/Ujo3GW+P4Jc98FlKWPRO9TqvM3bv9R6WfgGA3m/gl8bxPcBNRcInl+4GXuXvTpIEf9oUOraRR+0apK/emz7oISzhCCtHxQGSJU+BBHz2t9xb2hUFj4KVuKymC9pIr+BYaLAha3+/Pc9pUx/JppuZm7rj34NJtCyfbalPg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717490024; c=relaxed/simple; bh=WcdjXKp0usjBkPhOi1eWLnKB5YMWTKiIrOQDU48frSc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=G0dTxyRJmxQDkwMt9R8KmZsokT0u8gmHm85ryhyP6i3fMsEuBfDOM0NQIfSl+kwvt6Q6kpkqBdBtP5aJeE4PK/M0T57zGH0KYlKyeqa3jnftau02t19X9OwtYRwmd+RPLmgaJaY1wlCZla+D0OVzj94Dpb/50TG82N8pEuqZ4E0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qZfdi1+5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89DEBC2BBFC; Tue, 4 Jun 2024 08:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717490024; bh=WcdjXKp0usjBkPhOi1eWLnKB5YMWTKiIrOQDU48frSc=; h=From:To:Cc:Subject:Date:From; b=qZfdi1+5gE9tloM9plnd3OEOQJBcvuaiwPhWTsubkB3Hn1yhrHMBn2W32u+eBZSLB j3Px4R8aU+jzL2Q/Gm+E1qYhquQJGBWvOizcZVm5lVCTgwmCmcQK/Y/KK0Ww9amtbW lKZdaM1s5gQTgve53ySXMXBI7m43/erS8Hw7un8inpwt37c4JgVvBlmz9N3EJAuiVI 2wiAymER1ylE2RtZDuWBGJSPo3By47m53Oquc03Vua3beillfXm6uXsEBmSsTcyhyP bxBZbxuxsEC2pnQDkmSK90BXCeNIsoxqqJRuIdAsLSCidQusCgsedOFQ4DFn12ZeYd wbogKIXNYjCJA== From: Michael Walle To: Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , AngeloGioacchino Del Regno Cc: Jani Nikula , Chen-Yu Tsai , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michael Walle Subject: [PATCH RESEND] drm/mediatek/dp: fix spurious kfree() Date: Tue, 4 Jun 2024 10:33:37 +0200 Message-Id: <20240604083337.1879188-1-mwalle@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit drm_edid_to_sad() might return an error or just zero. If that is the case, we must not free the SADs because there was no allocation in the first place. Fixes: dab12fa8d2bd ("drm/mediatek/dp: fix memory leak on ->get_edid callback audio detection") Signed-off-by: Michael Walle Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Jani Nikula --- drivers/gpu/drm/mediatek/mtk_dp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 536366956447..ada12927bbac 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -2073,9 +2073,15 @@ static const struct drm_edid *mtk_dp_edid_read(struct drm_bridge *bridge, */ const struct edid *edid = drm_edid_raw(drm_edid); struct cea_sad *sads; + int ret; - audio_caps->sad_count = drm_edid_to_sad(edid, &sads); - kfree(sads); + ret = drm_edid_to_sad(edid, &sads); + /* Ignore any errors */ + if (ret < 0) + ret = 0; + if (ret) + kfree(sads); + audio_caps->sad_count = ret; /* * FIXME: This should use connector->display_info.has_audio from -- 2.39.2