From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cGNwB-0005Fh-L5 for mharc-grub-devel@gnu.org; Mon, 12 Dec 2016 05:34:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGNw6-0005C6-VP for grub-devel@gnu.org; Mon, 12 Dec 2016 05:34:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGNw3-0002OY-Fl for grub-devel@gnu.org; Mon, 12 Dec 2016 05:34:22 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:40765) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cGNw3-0002Nm-77 for grub-devel@gnu.org; Mon, 12 Dec 2016 05:34:19 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uBCAYHq4026648 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 12 Dec 2016 10:34:17 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id uBCAYGOX025673 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 12 Dec 2016 10:34:17 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uBCAYGd6018186 for ; Mon, 12 Dec 2016 10:34:16 GMT Received: from [10.162.81.165] (/10.162.81.165) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 12 Dec 2016 02:34:16 -0800 Subject: Re: [PATCH V2 1/4] ofnet: add error check for grub_netbuff_reserve To: The development of GNU GRUB References: <1480691405-15118-1-git-send-email-stanislav.kholmanskikh@oracle.com> <1480691405-15118-2-git-send-email-stanislav.kholmanskikh@oracle.com> <4bb922fb-7876-3cee-a6f9-a3410955f073@gmail.com> Cc: vasily.isaenko@oracle.com From: Stanislav Kholmanskikh Message-ID: <584E7D26.7070002@oracle.com> Date: Mon, 12 Dec 2016 13:34:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <4bb922fb-7876-3cee-a6f9-a3410955f073@gmail.com> Content-Type: text/plain; charset=utf-8 X-Source-IP: aserv0021.oracle.com [141.146.126.233] Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp1040.oracle.com id uBCAYHq4026648 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Dec 2016 10:34:26 -0000 On 12/10/2016 09:08 PM, Andrei Borzenkov wrote: > 02.12.2016 18:10, Stanislav Kholmanskikh =D0=BF=D0=B8=D1=88=D0=B5=D1=82= : >> Signed-off-by: Stanislav Kholmanskikh >> --- >> grub-core/net/drivers/ieee1275/ofnet.c | 6 +++++- >> 1 files changed, 5 insertions(+), 1 deletions(-) >> >> diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/dr= ivers/ieee1275/ofnet.c >> index 6bd3b92..8332d34 100644 >> --- a/grub-core/net/drivers/ieee1275/ofnet.c >> +++ b/grub-core/net/drivers/ieee1275/ofnet.c >> @@ -90,7 +90,11 @@ get_card_packet (struct grub_net_card *dev) >> return NULL; >> /* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is di= visible >> by 4. So that IP header is aligned on 4 bytes. */ >> - grub_netbuff_reserve (nb, 2); >> + if (grub_netbuff_reserve (nb, 2)) >> + { >> + grub_netbuff_free (nb); >> + return NULL; >> + } >> =20 >> start_time =3D grub_get_time_ms (); >> do >> >=20 > We already account for this reserve when we allocate netbuf. So this is > redundant. May be short comment before grub_netbuf_alloc to explain how > we get at final size. So your message is that since nb =3D grub_netbuff_alloc(some_len + 2) succeeds (i.e. returns a valid buffer), then following grub_netbuff_reserve(nb, 2) will never fail and needs no check for error. Right? Personally I don't like skipping such checks, but if you insist on removing the check, then, I think, all other drivers should be updated as well, because they all have the check. Thanks. >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >=20