drm/ttm: Fix a NULL pointer dereference
authorjsg <jsg@openbsd.org>
Tue, 28 Mar 2023 04:11:29 +0000 (04:11 +0000)
committerjsg <jsg@openbsd.org>
Tue, 28 Mar 2023 04:11:29 +0000 (04:11 +0000)
From Thomas Hellstrom
9ba1720f6c4a0f13c3f3cb5c28132ee75555d04f in linux-6.1.y/6.1.21
9a9a8fe26751334b7739193a94eba741073b8a55 in mainline linux

sys/dev/pci/drm/ttm/ttm_device.c

index c3dfc19..d4ad7ed 100644 (file)
@@ -154,7 +154,7 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,
                        struct ttm_buffer_object *bo = res->bo;
                        uint32_t num_pages;
 
-                       if (!bo)
+                       if (!bo || bo->resource != res)
                                continue;
 
                        num_pages = PFN_UP(bo->base.size);