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 F328B33E379 for ; Fri, 20 Feb 2026 12:05:34 +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=1771589136; cv=none; b=h143qrGnzNZT/XFpVuCzYOeLAq+9+i3dwi7f3Iz9V1uSExRhhRRrf67oVFOxASJLXDnAyiJPoxTbHEoQ/5K56gHgvHyBBZXxNaozphzqJJj+gGxhSbAmMMOZDJNvV9bgFkms3o7ixm8FbhI0x1o1vGXUXxv+ujhjK8QVFUZ4KZo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771589136; c=relaxed/simple; bh=i1pmzhUC01aPbdoemM4d+oI6KbPOiVUXkSO862e2/54=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eN//8YCh6n5ePY+ZwvbMbI+vnjHSTe1bd6YC1OevZH1sC83AGYWk/AhoC8m9qaROd4n5B9xmxVKbiDkhT85HM8LpUWPt72blZg6YScZGX2gF6mCjFFn5vLxANc6oL+fcY+OWVMgPrcAv4uREujjLL27cVmMbtXyTSem1hyxYkLI= 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=Adx/K79n; 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="Adx/K79n" 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=Y5NHx8cagTL1VgY86ncmN2FRKWUugvfw4l5iDGbIzlo=; b=Adx/K79nz8tT1JklBdqvszrRCi jbTrhi1gCBYqAik8z6hYrhrd80gdHjlRSeOobPkIN4DE86mdP1/GHmgU1QVE/nhQF80TANnku7u3w 5Q9nVW8TM6CnF2Vtxtb0JKn4mb/+ryl5vjH4q/1eUO3zRDQeSI3HgrQCXzoH4zzJP0M3FJprbhbbZ Z0xySwsXibAjRYVvhmF4ooi6Sb41wHxWUhSSAp3yHhtTe09rdFUlV9V/WK98B8M2Q5TZh0yFYQEG1 CmWf/uquzZ+dJDxlYewdswsiWy4ZwlTVmY1eTlANdUcgl30eGUt42MYIrPce5QzFFkQI0tzrdAEVY d+/7D+Hg==; 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 1vtPGH-002uzN-1Y; Fri, 20 Feb 2026 13:05:33 +0100 From: Tvrtko Ursulin To: criu@lists.linux.dev Cc: David Francis , Tvrtko Ursulin Subject: [RFC 11/26] plugins/amdgpu: Fix error handling in amdgpu_plugin_drm_restore_file() Date: Fri, 20 Feb 2026 12:04:59 +0000 Message-ID: <20260220120514.4540-12-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 Add missing error checking for failure to allocate memory, plus, actually free the memory on the failure exit path. Signed-off-by: Tvrtko Ursulin --- plugins/amdgpu/amdgpu_plugin_drm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/amdgpu/amdgpu_plugin_drm.c b/plugins/amdgpu/amdgpu_plugin_drm.c index 06976a81ce1a..9df755450dc9 100644 --- a/plugins/amdgpu/amdgpu_plugin_drm.c +++ b/plugins/amdgpu/amdgpu_plugin_drm.c @@ -454,8 +454,13 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd) bool retry_needed = false; uint32_t major, minor; amdgpu_device_handle h_dev; - int device_fd; - int *dmabufs = xzalloc(sizeof(int) * rd->num_of_bos); + int device_fd, *dmabufs; + + dmabufs = xzalloc(sizeof(int) * rd->num_of_bos); + if (!dmabufs) { + pr_err("Failed allocate memory for drm restore\n"); + return -ENOMEM; + } ret = amdgpu_device_initialize(fd, &major, &minor, &h_dev); if (ret) { @@ -573,9 +578,9 @@ int amdgpu_plugin_drm_restore_file(int fd, CriuRenderNode *rd) } exit: - if (ret < 0) - return ret; xfree(dmabufs); + if (ret < 0) + return ret; return retry_needed; } -- 2.52.0