Index: gotd/session_write.c
--- gotd/session_write.c.orig
+++ gotd/session_write.c
@@ -1113,7 +1113,6 @@ recv_packfile(struct gotd_session_client *client)
 	    GOTD_IMSG_PACKFILE_PIPE, PROC_SESSION_WRITE, pipe[0],
 	        NULL, 0) == -1) {
 		err = got_error_from_errno("imsg compose PACKFILE_PIPE");
-		pipe[0] = -1;
 		goto done;
 	}
 	pipe[0] = -1;
@@ -1121,8 +1120,10 @@ recv_packfile(struct gotd_session_client *client)
 	/* Send pack pipe end 1 to gotsh(1) (expects just an fd, no data). */
 	if (gotd_imsg_compose_event(&client->iev,
 	    GOTD_IMSG_PACKFILE_PIPE, PROC_SESSION_WRITE, pipe[1],
-	    NULL, 0) == -1)
+	    NULL, 0) == -1) {
 		err = got_error_from_errno("imsg compose PACKFILE_PIPE");
+		goto done;
+	}
 	pipe[1] = -1;
 
 	if (asprintf(&basepath, "%s/%s/receiving-from-uid-%d.pack",
@@ -1160,7 +1161,6 @@ recv_packfile(struct gotd_session_client *client)
 	    GOTD_IMSG_PACKIDX_FILE, PROC_SESSION_WRITE,
 	    idxfd, NULL, 0) == -1) {
 		err = got_error_from_errno("imsg compose PACKIDX_FILE");
-		idxfd = -1;
 		goto done;
 	}
 	idxfd = -1;
@@ -1173,7 +1173,6 @@ recv_packfile(struct gotd_session_client *client)
 	    GOTD_IMSG_RECV_PACKFILE, PROC_SESSION_WRITE, packfd,
 	    &ipack, sizeof(ipack)) == -1) {
 		err = got_error_from_errno("imsg compose RECV_PACKFILE");
-		packfd = -1;
 		goto done;
 	}
 	packfd = -1;
