A couple small changes:
 - Validate the magic value at the head of FWCCB commands, and
 - Mask off the magic value before logging unknown command types to make
   them easier to interpret on sight.

Signed-off-by: Matt Coster <[email protected]>
---
 drivers/gpu/drm/imagination/pvr_ccb.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imagination/pvr_ccb.c 
b/drivers/gpu/drm/imagination/pvr_ccb.c
index 9294b4ba1de7..2f4356a1e69f 100644
--- a/drivers/gpu/drm/imagination/pvr_ccb.c
+++ b/drivers/gpu/drm/imagination/pvr_ccb.c
@@ -136,6 +136,14 @@ pvr_ccb_slot_available_locked(struct pvr_ccb *pvr_ccb, u32 
*write_offset)
 static void
 process_fwccb_command(struct pvr_device *pvr_dev, struct rogue_fwif_fwccb_cmd 
*cmd)
 {
+       struct drm_device *drm_dev = from_pvr_device(pvr_dev);
+
+       if ((cmd->cmd_type & ROGUE_CMD_MAGIC_DWORD_MASK) != 
ROGUE_CMD_MAGIC_DWORD_SHIFTED) {
+               drm_warn_once(drm_dev, "Received FWCCB command with bad magic 
value; ignoring (type=0x%08x)\n",
+                             cmd->cmd_type);
+               return;
+       }
+
        switch (cmd->cmd_type) {
        case ROGUE_FWIF_FWCCB_CMD_REQUEST_GPU_RESTART:
                pvr_power_reset(pvr_dev, false);
@@ -151,8 +159,8 @@ process_fwccb_command(struct pvr_device *pvr_dev, struct 
rogue_fwif_fwccb_cmd *c
                break;
 
        default:
-               drm_info(from_pvr_device(pvr_dev), "Received unknown FWCCB 
command %x\n",
-                        cmd->cmd_type);
+               drm_info(drm_dev, "Received unknown FWCCB command (type=%d)\n",
+                        cmd->cmd_type & ~ROGUE_CMD_MAGIC_DWORD_MASK);
                break;
        }
 }

-- 
2.52.0

Reply via email to