From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBDB12D46CE for ; Sat, 15 Aug 2026 19:54:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786823674; cv=none; b=TwDiStWBvkNzIHbOSUyQVsn87MkbGazeu1wayo1RLn+mtqwTIiEGXU1MgaZZntKW6OJ9jNPKHoZgczbfM44UDiUfS0gtfSfwBZaLBASvpH618rbasCyTNiy4nH7X0vVSogHOX53/TkkycJROfXEMN1zoWOKpDt3NJxeTQJwl0aA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786823674; c=relaxed/simple; bh=vz4yJ/cF+ewIEn34giFknRSxk5Do94Q5VaPKWHzpTZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=IHq+Dg0wlPOJ3zZ6jGY4cR9s8UMXd8TRo56ZvYfP4OezpT+7+hMG4qs4crmlusyPL8oQXLW6pat905xv4nNdMXu/b9dk6inGefYVzuwtiFw2yBxVqot1WX68deBfm0ywWTsgXJCeTWidj/Qc0z5wCjmwS9JpXsWoxcTj64SMvUI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GQ3t7Vnz; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GQ3t7Vnz" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4957739c22fso618255e9.3 for ; Sat, 15 Aug 2026 12:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786823671; x=1787428471; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=LRzhc3yRX4X2M0pP9m+t3D39cWjJJWO0zjbMTBO7W2E=; b=GQ3t7VnzCG6oOI2u7P3U1jsz5QW2hI2zqmQFtTHJZ+elp33LEQnhiTSpBQTZQbw4gj qopFYdLgmZVSwl3AMl9cHhowSrHkIt4SNjBdBhxaE5x4bQzBBXt2zhix+4lJEmsVFvdB gPMqHzj6GoESQVzJLqAPHOKv414I+7XkxspSHakF6w10MrP9G7Lc3lXDsQ5JHZf+uRCT ggfafuvE7wKQ68ZLeZnhuJOzpv3c2W4WlLbwRhQt0bZUB7qyCsVUfJpPpSbMlq8O6uHD k3nCHQY9oBPRw+R9Q9HJZyMCDXRwzgFPOXdddWF+W+8gDXmiOHuLEixSaX1eHAV9Kqn4 uTPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786823671; x=1787428471; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=LRzhc3yRX4X2M0pP9m+t3D39cWjJJWO0zjbMTBO7W2E=; b=H1d4xr1CN3+CtQxbS4Px1dYJ4ettJwA7wN7EVJKYnALn/S51QQUkroJSQGnNEZ07DR jhIOcL6Qc1SV2gBZSsl9/OtxUbxB7sxJFPKDFINxvtvYN7HHNoQrHtjM0OxKl+ajl6iJ utJgj0ANnChAAY34UnnMwS3XqkTFZT155RkUPUPCxz3D4MIitV5ywy/LybbjiPS1p90I BUWroCTy+pDo7y7q6uSqkn+INmzr6UszXVS/GhjXuAaunI+aOpdyqzcyz0y5jafIMiQF jgz1eUzdcND21wLK8xAlwUoYNWJfiNuic1Gg2krPeHQuRkS4SbvQ/0L41qViESNP9jPF mezA== X-Gm-Message-State: AOJu0Yys0qQAIB1s6QTFHmF/lo3NQsuFCwGxbd5SpE3JZ+NC6ajoSc4n o+O5B0NhwwCtwLhda/q2FolJKbL/by39YtN3hIAxeBOFA3QBZU0tk2Q+ X-Gm-Gg: AR+sD11nekYPRg00GK5viuyluuwzYcWAuvmz9fj8DBxVDWDFM067Ofdnx3k8Rru8MJM bl1OJMuM7zkUu2NCHUjvGmhsq+Y0h+OVU7DskX+STPDbqVIDqFth2RTRArk7uP0e0wOIp6K5P0P T3Ox87uPMVjg4cbI5bcT+vHLvUC+M5mXljBUyMWtqHtQLge7412quAn3Gtod7SfRhzX4dbvo+h1 71uRIGIxQuYYklcwC2J/OrERj5xX9zsWyUqzIeB5p1dzVqMA6euziQRkVlmFCaXt3zSic7Pp2+7 ORVn0Ua0o17A2paajUJCEGmlXcpLEcWGuB4cnMpMepWiUZpjq1YCSLgQMUinAF+OetXLqVAW+UW jJnej6C/JgA++WtYzyBz2P/obnsBoVCeByj6TSIb0KyifuyRIdRKjty6yjCYtczViK/fEMEfMPJ 6QibzN5xpLmI/KZrSSI4OmHJcvki1LesavdYgZoIWmXDeDifaSXQjpc9MFIk2rpqL2zRbe3o27s xsxV5/JQ4HbZ1NOrbKqoi/X/O4p/48D7iVh6nsa6g== X-Received: by 2002:a05:600c:1c05:b0:492:4a7a:e415 with SMTP id 5b1f17b1804b1-4998795db2bmr142400025e9.2.1786823670870; Sat, 15 Aug 2026 12:54:30 -0700 (PDT) Received: from [127.0.0.1] (ip-109-193-028-127.um39.pools.vodafone-ip.de. [109.193.28.127]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499899bff2csm133743775e9.7.2026.08.15.12.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 12:54:30 -0700 (PDT) From: Marek Czernohous To: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, Danilo Krummrich , Lyude Paul , David Airlie , Simona Vetter Subject: [PATCH 3/3] drm/nouveau: don't dereference outp before checking it in nouveau_dp_irq Date: Sat, 15 Aug 2026 21:54:20 +0200 Message-ID: <178682366004.3748010.14933649768375463967@gmail.com> X-Mailer: python-smtplib In-Reply-To: <178682366001.3748010.7798811159846779765@gmail.com> References: <178682366001.3748010.7798811159846779765@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Marek Czernohous nouveau_dp_irq() looks the encoder up and dereferences it in the same breath, five lines before testing it: struct nouveau_encoder *outp = find_encoder(connector, DCB_OUTPUT_DP); struct nouveau_drm *drm = nouveau_drm(outp->base.base.dev); ... if (!outp) return; find_encoder() walks the connector's possible encoders and returns NULL when none of them matches the requested type, so the NULL test is not decoration: it is the author saying this can happen. The initialiser above it dereferences the same pointer regardless. The NULL test predates the dereference. commit 773eb04d14a1 ("drm/nouveau/disp: expose conn event class") turned nouveau_dp_irq() into a work callback, and since the drm pointer was no longer passed in as an argument it was recovered from the encoder in the declaration block, which put the dereference above the existing test. Move the drm lookup below the test. No functional change when outp is non-NULL. Fixes: 773eb04d14a1 ("drm/nouveau/disp: expose conn event class") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5 Signed-off-by: Marek Czernohous --- drivers/gpu/drm/nouveau/nouveau_dp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index 55691ec44aba..738802358d85 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c @@ -486,7 +486,7 @@ nouveau_dp_irq(struct work_struct *work) container_of(work, typeof(*nv_connector), irq_work); struct drm_connector *connector = &nv_connector->base; struct nouveau_encoder *outp = find_encoder(connector, DCB_OUTPUT_DP); - struct nouveau_drm *drm = nouveau_drm(outp->base.base.dev); + struct nouveau_drm *drm; struct nv50_mstm *mstm; u64 hpd = 0; int ret; @@ -494,6 +494,8 @@ nouveau_dp_irq(struct work_struct *work) if (!outp) return; + drm = nouveau_drm(outp->base.base.dev); + mstm = outp->dp.mstm; NV_DEBUG(drm, "service %s\n", connector->name); -- 2.54.0