From ecd4e93456dedaa6a30054fa939f57a3dd7551e2 Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Wed, 29 Apr 2026 15:08:38 +0800 Subject: [PATCH] pvr: add deferred RTA clear command to list after checking it's not NULL The code that adds deferred RTA clear transfer commands checks whether the newly allocated transfer command is NULL. However the list_addtail call is before the check, which means that the check does not prevent NULL dereference. Reorder the code to ensure no NULL transfer commands would ever be added to the deferred clear list. In addition, pvr_transfer_cmd_alloc() has already set the command buffer's error status when it returns NULL, so it's not needed to set it again. Fixes: 2eabbbe57d12 ("pvr: use linked list to back deferred clears") Signed-off-by: Icenowy Zheng Reviewed-by: Luigi Santivetti Part-of: --- src/imagination/vulkan/rogue/pvr_blit.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/imagination/vulkan/rogue/pvr_blit.c b/src/imagination/vulkan/rogue/pvr_blit.c index 9e70c9367af..eaaa1e1f294 100644 --- a/src/imagination/vulkan/rogue/pvr_blit.c +++ b/src/imagination/vulkan/rogue/pvr_blit.c @@ -2005,14 +2005,11 @@ static VkResult pvr_add_deferred_rta_clear(struct pvr_cmd_buffer *cmd_buffer, continue; transfer_cmd = pvr_transfer_cmd_alloc(cmd_buffer); + if (!transfer_cmd) + return VK_ERROR_OUT_OF_HOST_MEMORY; list_addtail(&transfer_cmd->link, &cmd_buffer->deferred_clears); - if (!transfer_cmd) { - return vk_command_buffer_set_error(&cmd_buffer->vk, - VK_ERROR_OUT_OF_HOST_MEMORY); - } - transfer_cmd->flags = PVR_TRANSFER_CMD_FLAGS_FILL; if (attachment->aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) {