From mboxrd@z Thu Jan 1 00:00:00 1970 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 452D6EAC7 for ; Fri, 10 Apr 2026 18:55:39 +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=1775847340; cv=none; b=dsoUXbTJPoVUtSYAbKRag054J9dz2GZsLLIe03bLEs12N9jJc7RGGqiIFuyf0wReQUwCI2PQnznMhuyZwTMcNPi5Eo44TwuCeKEdd9zHOcfMX7mWHo99HZnOXbA2nSCYkV0K6H72cI10glBb6hdImKqH45V/KghwQcktiH2Ks/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775847340; c=relaxed/simple; bh=hZWjgrNFenSq/qf9M91ejeXppS31ADMeEbYCj9hyTbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B23xeMGRlD44A9T2t3/ZbrhuP5xI88f+DxVY4dIl1XhUGfcLEjDr7uZDGvwq9e5xWZYySqNZLYUWi+VoJCv7Qy58ye8Sv35W8ZLBTbANtvi3Zuoa2kaPcone22ncsDI711PJ8+gcO62/7gudOU22QORpPJgjMtN12NsfKJY9xM4= 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=Wj5QrKhv; 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="Wj5QrKhv" 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=J1h6/BGx5J+MiPBjqGu3qzUk6tSNVs3ES1+TbK/VxqU=; b=Wj5QrKhvsuIkMPOiycGk+kv2/x QgZBf5GBKpo2ZtEsRZk92OaGWEgj5+5AV6Qvw9s8e2qFTN8SKY5nZKtKw8a+IZAIhNPFF4PkpEDN2 /zUD0EEC51r87Qu9eJBi13OQhsnbHyzxqQzHK2xJehoiG49ZizhzLDwMrLLan8mLm8gEK6xas/orM GATXLKW+T8j6F3wgZLde/OxVO8XApKjZpu7Xe/i0o2RsNoly39Lnz11dKI2KB/speWVjF+CIO1tGi BAzYmL1FXfTxPZwtK7xLwfAJnjf4WUjh5gmgmMDpwGpKR+ML7m7d7a9yvJWGu74pKmGgBsI7gDYQk LscyTEmw==; 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 1wBH0z-00EWU1-9T; Fri, 10 Apr 2026 20:55:37 +0200 From: Tvrtko Ursulin To: criu@lists.linux.dev Cc: Tvrtko Ursulin , David Francis Subject: [PATCH v2 08/23] plugins/amdgpu: Close dma-buf image file if the read fails Date: Fri, 10 Apr 2026 19:54:59 +0100 Message-ID: <20260410185514.51153-9-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260410185514.51153-1-tvrtko.ursulin@igalia.com> References: <20260410185514.51153-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 Consolidate to one fclose() call with the extra bonus the inconsequential file descriptor leak is eliminated. Signed-off-by: Tvrtko Ursulin Reviewed-By: David Francis --- plugins/amdgpu/amdgpu_plugin_dmabuf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/amdgpu/amdgpu_plugin_dmabuf.c b/plugins/amdgpu/amdgpu_plugin_dmabuf.c index e76628cc2faf..312c9f95d048 100644 --- a/plugins/amdgpu/amdgpu_plugin_dmabuf.c +++ b/plugins/amdgpu/amdgpu_plugin_dmabuf.c @@ -120,6 +120,7 @@ int amdgpu_plugin_dmabuf_restore(int id) } ret = read_fp(img_fp, buf, img_size); + fclose(img_fp); if (ret) { pr_perror("Unable to read from %s", path); xfree(buf); @@ -130,10 +131,8 @@ int amdgpu_plugin_dmabuf_restore(int id) if (rd == NULL) { pr_perror("Unable to parse the dmabuf message %d", id); xfree(buf); - fclose(img_fp); return -1; } - fclose(img_fp); /* Match GEM handle with shared_dmabuf list */ fd_id = amdgpu_id_for_handle(rd->gem_handle); -- 2.52.0