Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 A02D9340D9A for ; Fri, 20 Feb 2026 12:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589134; cv=none; b=YWw9y7nYbXSrgVqMN+oR48L+k8cc6T9mpTEtky5VQm872zD8faUfltPxIaOM4Vv4Bbfoiuq1+Y4KfyLh5jr1DgW0lsidpUJqayl2Oz8TpzKZsvRK5hOZqu06/DDKguty8jl4NmJAm6tlGW1IXDoirKO37Y4ml0th5/AIWyzI8SA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589134; c=relaxed/simple; bh=r6cAOzVx3VzS4yi7aDPx72ERRSNxNJKlD5S/ryvmFp4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nleFfTUT2K6LlGj2UJCSXkz9RaLW+Uk29E6rdrkr7Ut318taplXNmyKnbyoJTB8szbzLMU2A6Tehobw+zBXLBYOzzXbrB604vMkuAMlSCEUO76WozaYwmYW//Vsyn7Zl/pxma4Ou7jAl+/1jIsjvKEFiabekQoM9wc53zNzShIs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=Lg5omruR; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="Lg5omruR" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=JuRQOKgl5vfzqS378tR1bLvY0vVJZ5i85NoZBeJPdDM=; b=Lg5omruRXWFMFRZtyxzQpEW724 3RjCkhX6pBHNyrZ1dACpjve9jJIC9U0pePfP6wgud5nf9J4kPaP1Z/ZAWZQr92dINbLWG5+OIOzUd LSoQu4q/pbledWAjSbjOH9UP3bvzY+qZxbW+cVtqkN7K/NRVdTou4why4U+X1eUunSRCtGbOuDT30 gSiCeETY6xIG3pTLMTwQuzQl4VxhHHhtxFg6O6RDfyP7Tt0075UKdAC2EZqfJ12rUVVul5ai79HIH vEBmk1wZN+lwcjF0k9ACdOQuB1bXTAnghErBKV4H20cMM3dBJf8VaRkyY6gjhXf9tA/FCItg15v8v fvBWrTIQ==; Received: from [90.240.106.137] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vtPGF-002uz5-JM; Fri, 20 Feb 2026 13:05:31 +0100 From: Tvrtko Ursulin To: criu@lists.linux.dev Cc: David Francis , Tvrtko Ursulin Subject: [RFC 09/26] plugins/amdgpu: Check images were opened successfully Date: Fri, 20 Feb 2026 12:04:57 +0000 Message-ID: <20260220120514.4540-10-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> References: <20260220120514.4540-1-tvrtko.ursulin@igalia.com> Precedence: bulk X-Mailing-List: criu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Avoid potentially passing a NULL file pointer to fread/fwrite inside sdma_copy_bo() and therefore invoking undefined behaviour. Signed-off-by: Tvrtko Ursulin --- plugins/amdgpu/amdgpu_plugin_drm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/amdgpu/amdgpu_plugin_drm.c b/plugins/amdgpu/amdgpu_plugin_drm.c index 34014783c2d4..06976a81ce1a 100644 --- a/plugins/amdgpu/amdgpu_plugin_drm.c +++ b/plugins/amdgpu/amdgpu_plugin_drm.c @@ -210,6 +210,11 @@ static int restore_bo_contents_drm(int drm_render_minor, CriuRenderNode *rd, int snprintf(img_path, sizeof(img_path), IMG_DRM_PAGES_FILE, rd->id, drm_render_minor, i); bo_contents_fp = open_img_file(img_path, false, &image_size); + if (!bo_contents_fp) { + ret = -EIO; + pr_err("Failed to open BO image file %s\n", img_path); + break; + } ret = sdma_copy_bo(dmabufs[i], rd->bo_entries[i]->size, bo_contents_fp, buffer, buffer_size, h_dev, max_copy_size, SDMA_OP_VRAM_WRITE, true); @@ -380,6 +385,10 @@ int amdgpu_plugin_drm_dump_file(int fd, int id, struct stat *drm) snprintf(img_path, sizeof(img_path), IMG_DRM_PAGES_FILE, rd->id, rd->drm_render_minor, i); image_size = handle_entry.size; bo_contents_fp = open_img_file(img_path, true, &image_size); + if (!bo_contents_fp) { + ret = -EIO; + goto exit; + } posix_memalign(&buffer, sysconf(_SC_PAGE_SIZE), handle_entry.size); -- 2.52.0