Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp818833lqo; Fri, 17 May 2024 02:30:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVy+4rqs4rPor+HXH+dnxkDflZGskaxuD8R6SDI1nJ+ILeqrCepsEO2tTzNJdgCpos/oTexGudy0xZyG3uxDAqGxVBxRCW/hhpjY187ow== X-Google-Smtp-Source: AGHT+IFzCtyXibqoJy95QRT7pDvPi47Oj8n+389E8dTKb09eklNarAEboZ3LX5TNO1xIslwURfub X-Received: by 2002:a17:907:9455:b0:a59:b88c:2b2a with SMTP id a640c23a62f3a-a5a2d66a7cdmr1706435666b.50.1715938242064; Fri, 17 May 2024 02:30:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715938242; cv=pass; d=google.com; s=arc-20160816; b=KGjvN2LC6VJDKmQ6mfdm8n1XbeBT9HBgVbun+BSPSlX7mse46qAz1FpZnxWJY4bSvN abkmMi9NWMyMsuegVR0aeI/2WyK6/p8xtVZulnAyGOvg5mH3cc7CPPp+WuJ/Lj4Mq1po ml36OiwtJNj6loRr6FqYiRKSvt0oaqR4hkqlSSpctHWVwdPh4GfA3vjnVB4N/ETDPSdk v75dJINDclPh2KW1WtVockAjx7Ti3u2JPWL7ZeTV18luzwXhBa7znJW9WQ4rWl1pFC+Q jMxihu4KDtxABKQvFDaeZNTAcHbvlcu/DwL0rqnq3ElXAMuq79s12SV2eKpTfA8GMKPK dQdA== 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=GTlnCi7AzbNoF5CmVZPFQOFsREJaSB9TFOOPDhFQIW0=; fh=HhZMsY/bhQjK83kvAH0bOzWCn/Zg0/zDVIgHHPeorEo=; b=YmvFTQSF1cKh9gtF0foNfz3c3FQWhyUHnhUo6ZVFoCpfgP/oPa/IXfgbqQjXvP2Z9l tkAimcPVZLvcMUYguNgR5DVQ/Ktl0XgXxgA2JPMfdntQHxf665h9JcB3XcrRqOJGRNxa IGfpZ/9jtVa7kcjvlD2KtxLBGZjk5RUYDu7JwvdBxArVHcgQAAzFNKOS1GUHLEMxUtN0 dhkbW+KDByZ/fwZYV+XcG/0n6TC79t/uVglVBSNKXJTUBBEvddQKzS++CYNbHWHp3rdO nMLGVvYZSGTme88xZ1TJdqWM/AHzddpkzzXd2hqGxDVRd1CSackZFn16Z6/Nsa5C+Isv 0+HA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bmH5v00w; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-181930-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181930-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 4fb4d7f45d1cf-5733beac399si10115919a12.111.2024.05.17.02.30.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 02:30:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181930-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=bmH5v00w; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-181930-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181930-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 C79BE1F2219B for ; Fri, 17 May 2024 09:30:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A453F224D6; Fri, 17 May 2024 09:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bmH5v00w" 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 D0A3B18AE0 for ; Fri, 17 May 2024 09:30:35 +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=1715938235; cv=none; b=exZxGs4R3WX1XqHE5iL05uszT4vZ+0CQd1AskTH1WBHSVmbvV1dzUDVebM1gdlpfPU99aKmgUBdLmJJVXgNXdrMXoqSFPi+hM1/CGRUCR6AyJ1Ri1i9nuYq0Hgx+WbjwT/NrNzrfHTYbf4kCvwJ+N6u81qJ/y9bvcaYsnYBa5Lg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715938235; c=relaxed/simple; bh=0Ppg0DAmyJKW6/IVs6KUizB75FN0TSYnPMZbnsVDHgs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=PvgTuj7ClgPP52a0k2jkLAchgXY7RAECFrVgPRZyyTRHwQYEkfHh3Ali1YGveXHMHkS19OnePU0B8B8j92rLcYnZFG76TaBxgNRln8Nir6nVlo/QJQqWlljZt5sxDwRRchm7ACBnHpHQapkxEYvfcjWJllWT2oexeyNZobTxXQE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bmH5v00w; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1284C2BD10; Fri, 17 May 2024 09:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715938235; bh=0Ppg0DAmyJKW6/IVs6KUizB75FN0TSYnPMZbnsVDHgs=; h=From:To:Cc:Subject:Date:From; b=bmH5v00wYUvLkqz9+qA8rWRCupLwX1m5hMeQDJUs2qwYwkbzF9ljuNOloc11WvjyP hvUSG9PXL4eIZwZp0lRZmjOam88aPbFXJDXvDchIm6iWfQ628f88uEx0xNhlri7gSG mE0fl0sBvBSVlreZ+Kwjf6A5Cx7UNduJJ4D08U50oibH27oiPdvytGeH1FG/Ib7o29 D8KnrhHLu8YBqtv+4OZLc85M438kcmrOREv46vm1cjXNLK1s3bvEVZ+H6Y52UoBBEB K6vQl5keKuLDsify+oRjgAmE65x4Gpb4zBidqZ5M/5H3R6b8ZzTJ3z7w8DZeM7zrlD Zxti9UU8qPyIA== 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] drm/mediatek/dp: fix spurious kfree() Date: Fri, 17 May 2024 11:30:24 +0200 Message-Id: <20240517093024.1702750-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 --- 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