From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cFm5l-0004L4-I6 for mharc-grub-devel@gnu.org; Sat, 10 Dec 2016 13:09:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cFm5h-0004Kw-AT for grub-devel@gnu.org; Sat, 10 Dec 2016 13:09:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cFm5d-0008SW-Hd for grub-devel@gnu.org; Sat, 10 Dec 2016 13:09:45 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34665) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cFm5d-0008S2-An for grub-devel@gnu.org; Sat, 10 Dec 2016 13:09:41 -0500 Received: by mail-lf0-f67.google.com with SMTP id x143so2679570lfd.1 for ; Sat, 10 Dec 2016 10:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=VqZNZ56elSsVXkTjF3sE7rD49K+ndG4IZobT2MFehqU=; b=f5atrLEjAQlMsMakuW4lbDublWWfBQ/1tiKSd0ur6FN8t66UE/34LgbvFcw/FNZ/WP x+vJoQoGRAZ/Zbl3Ah8/Xj4yVU+VxxgL0D2zjDSpwx5iICMGvOzEKNifJoJUneXu8Rtj D2YjN/m1r+MwlzRT8Kkn9DIHvw8ONLqyue0KnBrNWfVP0oukFeUbUBRdTu0b/6lCbucC z5KvRcaGFIV4MGrDWR3RU7GKf121Udr2Vwl/GRaQsp9D0ETdll9ctykXBVgEoYL7UBC2 P9MNpEvyfEXvdsymXntNm77NLr5OZ4KcCIwE87GdVDfINNfyVC2rm+R2kmWNHEPrQPHY m5iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=VqZNZ56elSsVXkTjF3sE7rD49K+ndG4IZobT2MFehqU=; b=fTCvuBF7GcDee7uxvs5Y0YPdyf/EdFkqGLZIXWY8uqw+RL6llDCGKhUkdwzVZ/7P7j g0AQFbHNbvAFmw23YkB2iOpF36mncC1ibhZukHPiUiLEP8h15yUSL9Xj8po5OylsJtwF 2n2ICuMQ35dnTygAXjCTumznVakOWzJkuRq9qomB7thcrz2OkWNVjoWp3e8XKDi7Ip86 aw9o4pJXKrSiW5JagBaEU6aqB/fK2zHGVw3Z4zYfq3u9KITttyxiKS5ERe742x6V2Kkk Nb7KzyWT2I5tg5LbdVQSrtM5NCHH8m7e5TAiJrlQgWY5ByT2ScdQcwmT+P6b1mcO431M WBLg== X-Gm-Message-State: AKaTC03LvNtM+tKq3TRZOszuUYh2wmSa4ELUDsQ0wvh2maeG08PgnYqCR+M/CojrGlf+Nw== X-Received: by 10.46.5.71 with SMTP id 68mr20524706ljf.13.1481393319993; Sat, 10 Dec 2016 10:08:39 -0800 (PST) Received: from [192.168.1.44] (ppp109-252-90-110.pppoe.spdop.ru. [109.252.90.110]) by smtp.gmail.com with ESMTPSA id f42sm7460235lji.2.2016.12.10.10.08.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Dec 2016 10:08:39 -0800 (PST) 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> Cc: vasily.isaenko@oracle.com From: Andrei Borzenkov Message-ID: <4bb922fb-7876-3cee-a6f9-a3410955f073@gmail.com> Date: Sat, 10 Dec 2016 21:08:38 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1480691405-15118-2-git-send-email-stanislav.kholmanskikh@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.215.67 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: Sat, 10 Dec 2016 18:09:49 -0000 02.12.2016 18:10, Stanislav Kholmanskikh пишет: > 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/drivers/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 divisible > 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; > + } > > start_time = grub_get_time_ms (); > do > 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.