From patchwork Mon Feb 19 20:21:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alvin_=C5=A0ipraga?= X-Patchwork-Id: 203263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp21655dyc; Mon, 19 Feb 2024 12:22:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVPSbOLbhQgxwunt27lMVLiDXtq63J2PQostHpXVvB7lJhIFnFfrG4UqZMTtIg30piZSUtaKpbF2xLIFlAWHAnvFdDXTQ== X-Google-Smtp-Source: AGHT+IFZnrvYcUoC3vm13cWicB/PCzccgY9jYOjLjUHqsMiGaG78B3sibe0HNbeIjsVKya059pkO X-Received: by 2002:a25:fc26:0:b0:db9:9134:bb28 with SMTP id v38-20020a25fc26000000b00db99134bb28mr10516380ybd.4.1708374135167; Mon, 19 Feb 2024 12:22:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708374135; cv=pass; d=google.com; s=arc-20160816; b=1ESwFBxyr/PlbVncncPWhw842vNcfSYsKAvkW26/RjCGyQCyM//rmwXKhyxRFbc0Mw rgUjcJRvgzFBZCGv3i9v9op8YRdNSYnatykfeeLYdLRQo/q1YgjfKMRMVqtKyk/Pzj7s ZlbVO8jY4sYglLZkERYJCq6+vRcU/X0fVfHA4XxUH6jKbq6mzOUaDSHx2CtaW8j6Fm3A tQW3v4WK9klwj3bFjOYjXHYwBrVyFpDUE6fDL1iehRTK1vEcOKMCbfi3mHLRA2RG3OHH +EdxaiU4s3DMcggJzUQZ7zMEeuPVe+Gj+ogu4I+ffPHmzj6XpM9Otp4okz601VsyIn+D 0czA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=kp0URhMfvWbpdkL0k/GUMkRRGYQFzEpfZ2mEHZ+rImI=; fh=S7N9+5zJMe6R/S/nVTOvlvFc0A1/72GgvdJ8iow7oK0=; b=pVfv2aN+SZfB0Sh9/M6u7gXdW3TlWUwaSqW0RBckFeny87X5ZeFIF2b9ifE08uGIMl psr9qLT4uYwNkokcIAAqBLL+fwcwmxVkfzcchc8odMZ/xkP6OKV+mm6HC+DGkJz0t354 hcC9taM22ttXdA8SVzlER01GiCt2JZLuKImpDCEhtXb1IN6EgAsW5a7IdgqpjwzJTn1a zJG4VPGysy3q2b3PrzYLTSpvKvmNO/UWG+e+BXeSH/bi3lAsOrGAme6WL/vnjggtbzEq 1FoxwCwVZubB5tnDY9Zo/gb//4HQqE9vs7wkbIxePNhLmh8h1XMRp7QmeG65g23QGDN8 dzZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b=vJuDBtbJ; arc=pass (i=1 spf=pass spfdomain=pqrs.dk dkim=pass dkdomain=pqrs.dk); spf=pass (google.com: domain of linux-kernel+bounces-71955-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71955-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c8-20020a37e108000000b0078770020413si1531619qkm.58.2024.02.19.12.22.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 12:22:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71955-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b=vJuDBtbJ; arc=pass (i=1 spf=pass spfdomain=pqrs.dk dkim=pass dkdomain=pqrs.dk); spf=pass (google.com: domain of linux-kernel+bounces-71955-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71955-ouuuleilei=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E4F531C21423 for ; Mon, 19 Feb 2024 20:22:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F476535C9; Mon, 19 Feb 2024 20:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pqrs.dk header.i=@pqrs.dk header.b="vJuDBtbJ" Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (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 37A9050272 for ; Mon, 19 Feb 2024 20:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708374120; cv=none; b=NosEm2wT7XI65wk2pwPVcaHpx4kcJo9Kn9WYqe8R2RnZ1uANBSPOKZDl2y6xBU3ZBhtl6Cn20DSFZTBNZjI4aEy27RNirWZu4NsYza/kQ4dhAvkPUq2N/oiKBL41ta1t59LBBioh7TGmO59h+wQL/ACZlWoCDzu1K0HJK8vmywU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708374120; c=relaxed/simple; bh=NadXeNdqAB/nYs/a/J52wOKf5x7jp+wtAwDpZbHVNsU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=rovoYNEG26gCJae06Tnm/1V0j0D1uHAQxYU49vy2uhMqm4O4AI2cqY5N6CuNN359FLakGO0Fg1kIkyZVttTUFOdz8fObvV4iZFHGZA0YhNGcQPJHWQRtMOVeom+VoWOH0fcC5ivgkVtPAFqywqJVrSuLLMBY1iIhUStSjyp+wwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pqrs.dk; spf=pass smtp.mailfrom=pqrs.dk; dkim=pass (2048-bit key) header.d=pqrs.dk header.i=@pqrs.dk header.b=vJuDBtbJ; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pqrs.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pqrs.dk X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=key1; t=1708374116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kp0URhMfvWbpdkL0k/GUMkRRGYQFzEpfZ2mEHZ+rImI=; b=vJuDBtbJv9vc8nkDV5W8HkNi/RotiChvYxU+iCCH//5OXnSXXFLGWEXjMo12APQduibzSs pUJdHP+aXrcsFVW2MF32O6dUnXcUTI1zU7ssWLM89GcKv7C0jPVonulxbEXvdinALRv0hY 4Op3EwWKB+DhT+hzTdwpTGpcq5xWkAZlzx//r9qtE5pHaHr2IuNBjUzRO4MzQHOMbWUm0r qXjuh9Ycf+HOkXCYUSvPM4djzYi6V3x4wcIOFwTp9BuXQgsnVyPDDC9tp12sOPVJbimF34 Ll5Bod0/JPiQvSviwcq0oUqdrNuMgKoyY98BOTSXDoTasebmIcyAPiKEEBm17A== From: =?utf-8?q?Alvin_=C5=A0ipraga?= Date: Mon, 19 Feb 2024 21:21:47 +0100 Subject: [PATCH v2] drm/bridge: adv7511: fix crash on irq during probe Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240219-adv7511-cec-irq-crash-fix-v2-1-245e53c4b96f@bang-olufsen.dk> X-B4-Tracking: v=1; b=H4sIAFq402UC/42OSw7CMAxEr1J5jVHdlH5YcQ/URUgcaoHakkAEq nJ3Qk/A8o00b2aFwF44wLFYwXOUIPOUodoVYEY9XRnFZoaqrBSVVKO2sT0QoWGD4h9ovA4jOnl j46zty15Z02rI/cVzjjf3ecg8SnjO/rNNRfql/1gjIaFSXV93jelUq06XfAvn+8sFnvb2BkNK6 Qs4CESPyAAAAA== To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Archit Taneja , Hans Verkuil Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mads Bligaard Nielsen , =?utf-8?q?Alvin_=C5=A0ipraga?= X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791360117146887080 X-GMAIL-MSGID: 1791360117146887080 From: Mads Bligaard Nielsen Moved IRQ registration down to end of adv7511_probe(). If an IRQ already is pending during adv7511_probe (before adv7511_cec_init) then cec_received_msg_ts could crash using uninitialized data: Unable to handle kernel read from unreadable memory at virtual address 00000000000003d5 Internal error: Oops: 96000004 [#1] PREEMPT_RT SMP Call trace: cec_received_msg_ts+0x48/0x990 [cec] adv7511_cec_irq_process+0x1cc/0x308 [adv7511] adv7511_irq_process+0xd8/0x120 [adv7511] adv7511_irq_handler+0x1c/0x30 [adv7511] irq_thread_fn+0x30/0xa0 irq_thread+0x14c/0x238 kthread+0x190/0x1a8 Fixes: 3b1b975003e4 ("drm: adv7511/33: add HDMI CEC support") Signed-off-by: Mads Bligaard Nielsen Signed-off-by: Alvin Šipraga --- Changes in v2: - rebase on latest drm-misc-fixes - no other changes - RESEND - Link to v1: https://lore.kernel.org/r/20231014-adv7511-cec-irq-crash-fix-v1-1-3389486c8373@bang-olufsen.dk --- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) --- base-commit: 335126937753844d36036984e96a8f343538a778 change-id: 20231014-adv7511-cec-irq-crash-fix-6fdd9093dc7a diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index 8be235144f6d..6fc292393c67 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1277,17 +1277,6 @@ static int adv7511_probe(struct i2c_client *i2c) INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work); - if (i2c->irq) { - init_waitqueue_head(&adv7511->wq); - - ret = devm_request_threaded_irq(dev, i2c->irq, NULL, - adv7511_irq_handler, - IRQF_ONESHOT, dev_name(dev), - adv7511); - if (ret) - goto err_unregister_cec; - } - adv7511_power_off(adv7511); i2c_set_clientdata(i2c, adv7511); @@ -1311,6 +1300,17 @@ static int adv7511_probe(struct i2c_client *i2c) adv7511_audio_init(dev, adv7511); + if (i2c->irq) { + init_waitqueue_head(&adv7511->wq); + + ret = devm_request_threaded_irq(dev, i2c->irq, NULL, + adv7511_irq_handler, + IRQF_ONESHOT, dev_name(dev), + adv7511); + if (ret) + goto err_unregister_audio; + } + if (adv7511->info->has_dsi) { ret = adv7533_attach_dsi(adv7511); if (ret)