From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aePvm-0001wq-8M for mharc-grub-devel@gnu.org; Fri, 11 Mar 2016 11:28:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aePvj-0001vH-Gc for grub-devel@gnu.org; Fri, 11 Mar 2016 11:28:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aePvf-0001z2-Bx for grub-devel@gnu.org; Fri, 11 Mar 2016 11:28:47 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:22911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aePvf-0001yu-47 for grub-devel@gnu.org; Fri, 11 Mar 2016 11:28:43 -0500 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id u2BGPMtX003823 for ; Fri, 11 Mar 2016 08:28:40 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=ifmXjKx1rrVZN16W1NI3uBdzt+Kpcsr7dUMin/yjD/U=; b=Xm1sIOeWLTZR9IHEBdBC4RHHusq/T5evG4yiwxcZBW/FSQDtuy7fSuEk8HfHmri3atmD KzmSx3nUoccTyRNP95IObn4UL/OfztWUlZJA/i5T1dHiBl2Fkj+vfxlQr7q8PQig1+y6 qa5kR/PJD5Y/5Za3ZDvHfFZSh8TqY/+BiUo= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 21kwmj15q7-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Fri, 11 Mar 2016 08:28:40 -0800 Received: from localhost (192.168.52.123) by mail.thefacebook.com (192.168.16.20) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 11 Mar 2016 08:28:37 -0800 From: Josef Bacik To: , Subject: [PATCH 1/3] push/pop errno in initrd read file path Date: Fri, 11 Mar 2016 11:28:33 -0500 Message-ID: <1457713715-31708-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-03-11_08:, , signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.145.42 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Mar 2016 16:28:48 -0000 If you try to load an initrd from http and it errors out we will free the initrd context but continue on because net_tcp_socket_close() will reset the grub_errno as will grub_initrd_close(). So we'll lose the errno and return GRUB_ERR_NONE instead of the original error. Add push/pulls to the appropriate places so we don't lose our errno. Thanks, Signed-off-by: Josef Bacik --- grub-core/loader/linux.c | 2 ++ grub-core/net/http.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index be6fa0f..bd61ca2 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -202,7 +202,9 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->components[i].file = grub_file_open (fname); if (!initrd_ctx->components[i].file) { + grub_error_push (); grub_initrd_close (initrd_ctx); + grub_error_pop (); return grub_errno; } initrd_ctx->nfiles++; diff --git a/grub-core/net/http.c b/grub-core/net/http.c index 4684f8b..0eeb2f6 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -406,7 +406,9 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) err = grub_net_send_tcp_packet (data->sock, nb, 1); if (err) { + grub_error_push (); grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT); + grub_error_pop (); return err; } -- 2.5.0