accel/qaic: Fix NULL pointer deref in qaic_destroy_drm_device()
authorJeffrey Hugo <quic_jhugo@quicinc.com>
Fri, 2 Jun 2023 21:04:40 +0000 (15:04 -0600)
committerJeffrey Hugo <quic_jhugo@quicinc.com>
Fri, 9 Jun 2023 17:07:28 +0000 (11:07 -0600)
If qaic_destroy_drm_device() is called before the device has fully
initialized it will cause a NULL pointer dereference as the drm device
has not yet been created. Fix this with a NULL check.

Fixes: c501ca23a6a3 ("accel/qaic: Add uapi and core driver file")
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Carl Vanderlip <quic_carlv@quicinc.com>
Reviewed-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230602210440.8411-3-quic_jhugo@quicinc.com
drivers/accel/qaic/qaic_drv.c

index 961cd341b4141f7fe5135f07a313267df206e81b..b5ba550a0c0400e03d3875bcbc5095c73582c06d 100644 (file)
@@ -225,6 +225,9 @@ static void qaic_destroy_drm_device(struct qaic_device *qdev, s32 partition_id)
        struct qaic_user *usr;
 
        qddev = qdev->qddev;
+       qdev->qddev = NULL;
+       if (!qddev)
+               return;
 
        /*
         * Existing users get unresolvable errors till they close FDs.