From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 A8A5B25B08A for ; Wed, 22 Jul 2026 00:59:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784681990; cv=none; b=UbPiahvKIQjXHvcN+TaSDRP/WVyQ2WhRn7ULB428hG2TpyCXSrahZsJQ7SYF66MzCmAeWcyzie72tGstCdhb8y5W3ToGuz0xd6FzlQGgsfvfpRWnZPx6yEIpOmb8HWeZwJ2CVnbXHgGZr109giOxqdJz9KZbR6JV0hL2GgrHoto= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784681990; c=relaxed/simple; bh=40q7PBGkLuW5l0eUB4WAtJACCsiHsKu6KuMFXOoMEhw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FoXiUeNF3mr6ZlOl0c7EMSAZWWe5amLYKSGxoem4hydUJ0DjzLXNYj3cUSyTt6lkanX7hQzBAk0ctEkmJzd2jzZLLqhvxRH2QtP0QC/L8SMIh4LPdBYo2Fw8ZBbzlONrCjwT6NnWhIi/T+GENJPgqxVyBDKm1tQ0wyZ3nVsWztA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1wmLJF-000000000zf-0Aua; Wed, 22 Jul 2026 00:59:41 +0000 Date: Wed, 22 Jul 2026 01:59:37 +0100 From: Daniel Golle To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Luca Ceresoli , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Matthias Brugger , AngeloGioacchino Del Regno , Hermes Wu , Allen Chen , Pin-yen Lin , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Chen-Yu Tsai Subject: [PATCH v4 3/5] drm/bridge: it6505: guard against zero channel count in audio infoframe Message-ID: <94721d5c75645a574263cc849249c56e504c2ade.1784681487.git.daniel@makrotopia.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: it6505->audio.channel_count is zero from allocation until either DP link training has run once (it6505_variable_config()) or a valid hw_params call has cached a channel count. it6505_enable_audio() can be reached before either of those has happened, e.g. from the audio-FIFO-error IRQ, which is unmasked unconditionally at poweron. it6505_enable_audio_infoframe() then indexes the 8-entry audio_info_ca[] table with channel_count - 1, an out-of-bounds stack read when channel_count is still 0. Bail out of it6505_enable_audio_infoframe() when channel_count is not yet known instead of indexing with it. While here, fix the debug print in it6505_audio_setup_hw_params(): on the invalid-channel-count path it logged the previously cached channel_count instead of the actually-rejected params->cea.channels. Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver") Signed-off-by: Daniel Golle Reviewed-by: Chen-Yu Tsai --- v4: no changes v3: new patch, split out to fix pre-existing bugs flagged by automated review of v2's audio series; needed before that series starts exercising the audio-FIFO-error IRQ path in a configuration where channel_count == 0 is actually reachable. drivers/gpu/drm/bridge/ite-it6505.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 2a8298ee6c03..443ea5579744 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -1575,6 +1575,9 @@ static void it6505_enable_audio_infoframe(struct it6505 *it6505) struct device *dev = it6505->dev; u8 audio_info_ca[] = { 0x00, 0x00, 0x01, 0x03, 0x07, 0x0B, 0x0F, 0x1F }; + if (!it6505->audio.channel_count) + return; + DRM_DEV_DEBUG_DRIVER(dev, "infoframe channel_allocation:0x%02x", audio_info_ca[it6505->audio.channel_count - 1]); @@ -2991,7 +2994,7 @@ static int __maybe_unused it6505_audio_setup_hw_params(struct it6505 *it6505, if (params->cea.channels <= 1 || params->cea.channels > 8) { DRM_DEV_DEBUG_DRIVER(dev, "channel number: %d not support", - it6505->audio.channel_count); + params->cea.channels); return -EINVAL; } -- 2.55.0