From nobody Thu Nov 28 19:51:51 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 C316D1C2449 for ; Fri, 27 Sep 2024 20:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469996; cv=none; b=hO6H5rYdbBsGqPnCOeKrs5zlHUjtOS3Y9b3YbiV7Ohu1kE6cBYgUQ4IGqiF8CkO1+hs8qBuNan7ET/6g/VmGywCA2sIjO+blvSxCs0X98KB5W1ptUuSJTpRmQeaLHSpzkdEPUtP3ZZs9DlGRUSXdx6xebuW8BzaLNihPizuiSNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469996; c=relaxed/simple; bh=X0Tu1fbU3iFzETxLdIRaXrvnVItQS17Cn5VyrEtUYCk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fvHDrBRSHL9Iu2LZYuDRiiUNL+vidXUUunZSR1Bu7JQLlfC10y8/bjWVKCpziJ3PcgH1rlzQZtBOY5uf4qsm6HXwgrRCF+6mQR6qlUWjGs8jEWc+LF6j50ekPjOA/UHun39mUDWTD11JfSNu0LrYZBPOu1BFkIF7ARtgpSKuSyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OV5lJ64d; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OV5lJ64d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727469990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=UW32wAnMjxA4S/oz9w5qOVbyTn2kSOgb6EUyptzsUfM=; b=OV5lJ64dbcAJ1jVxKlfgEP1ZCzEebSs1YfvSqh8HEbWV/mbpUKqD1St+3HHmUIaqI+j8dq x9Qb7oaAFyzO8y5Whp7euQzmTFIrxUX4WwBLHQlWsSwN3CdnTdpl5P1+hfFhM3AZ9WWC+h 0rJoYQkPmvLzemmCQ230CGZlnvxkPOw= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-KIOkFG8FM3Wgg1-uDgKCGg-1; Fri, 27 Sep 2024 16:46:29 -0400 X-MC-Unique: KIOkFG8FM3Wgg1-uDgKCGg-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 06F9519103FE; Fri, 27 Sep 2024 20:46:28 +0000 (UTC) Received: from chopper.redhat.com (unknown [10.22.32.36]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A19C219560A3; Fri, 27 Sep 2024 20:46:25 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org Cc: stable@vger.kernel.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Sean Paul , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/atomic_helper: Add missing NULL check for drm_plane_helper_funcs.atomic_update Date: Fri, 27 Sep 2024 16:46:16 -0400 Message-ID: <20240927204616.697467-1-lyude@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Something I discovered while writing rvkms since some versions of the driver didn't have a filled out atomic_update function - we mention that this callback is "optional", but we don't actually check whether it's NULL or not before calling it. As a result, we'll segfault if it's not filled in. rvkms rvkms.0: [drm:drm_atomic_helper_commit_modeset_disables] modeset on= [ENCODER:36:Virtual-36] BUG: kernel NULL pointer dereference, address: 0000000000000000 PGD 0 P4D 0 Oops: Oops: 0010 [#1] PREEMPT SMP NOPTI Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-20240813-1.= fc40 08/13/2024 RIP: 0010:0x0 So, let's fix that. Signed-off-by: Lyude Paul Fixes: c2fcd274bce5 ("drm: Add atomic/plane helpers") Cc: dri-devel@lists.freedesktop.org Cc: # v3.19+ Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/drm_atomic_helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atom= ic_helper.c index 43cdf39019a44..b3c507040c6d6 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2797,7 +2797,8 @@ void drm_atomic_helper_commit_planes(struct drm_devic= e *dev, =20 funcs->atomic_disable(plane, old_state); } else if (new_plane_state->crtc || disabling) { - funcs->atomic_update(plane, old_state); + if (funcs->atomic_update) + funcs->atomic_update(plane, old_state); =20 if (!disabling && funcs->atomic_enable) { if (drm_atomic_plane_enabling(old_plane_state, new_plane_state)) @@ -2889,7 +2890,8 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_cr= tc_state *old_crtc_state) if (disabling && plane_funcs->atomic_disable) { plane_funcs->atomic_disable(plane, old_state); } else if (new_plane_state->crtc || disabling) { - plane_funcs->atomic_update(plane, old_state); + if (plane_funcs->atomic_update) + plane_funcs->atomic_update(plane, old_state); =20 if (!disabling && plane_funcs->atomic_enable) { if (drm_atomic_plane_enabling(old_plane_state, new_plane_state)) base-commit: 22512c3ee0f47faab5def71c4453638923c62522 --=20 2.46.1