From: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: vasily.isaenko@oracle.com
Subject: Re: [PATCH V2 1/4] ofnet: add error check for grub_netbuff_reserve
Date: Mon, 12 Dec 2016 13:34:14 +0300 [thread overview]
Message-ID: <584E7D26.7070002@oracle.com> (raw)
In-Reply-To: <4bb922fb-7876-3cee-a6f9-a3410955f073@gmail.com>
On 12/10/2016 09:08 PM, Andrei Borzenkov wrote:
> 02.12.2016 18:10, Stanislav Kholmanskikh пишет:
>> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
>> ---
>> 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.
So your message is that since nb = 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.
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
next prev parent reply other threads:[~2016-12-12 10:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 15:10 [V2] Implementing the receive buffer for ofnet Stanislav Kholmanskikh
2016-12-02 15:10 ` [PATCH V2 1/4] ofnet: add error check for grub_netbuff_reserve Stanislav Kholmanskikh
2016-12-05 15:49 ` Daniel Kiper
2016-12-10 18:08 ` Andrei Borzenkov
2016-12-12 10:34 ` Stanislav Kholmanskikh [this message]
2016-12-12 12:10 ` Andrei Borzenkov
2016-12-02 15:10 ` [PATCH V2 2/4] ofnet: move the allocation of the transmit buffer into a function Stanislav Kholmanskikh
2016-12-05 15:52 ` Daniel Kiper
2016-12-12 9:47 ` Stanislav Kholmanskikh
2016-12-12 10:27 ` Andrei Borzenkov
2016-12-12 10:38 ` Stanislav Kholmanskikh
2016-12-02 15:10 ` [PATCH V2 3/4] ofnet: free memory on module unload Stanislav Kholmanskikh
2016-12-05 16:02 ` Daniel Kiper
2016-12-10 18:18 ` Andrei Borzenkov
2016-12-12 9:56 ` Stanislav Kholmanskikh
2016-12-02 15:10 ` [PATCH V2 4/4] ofnet: implement the receive buffer Stanislav Kholmanskikh
2016-12-05 16:12 ` Daniel Kiper
2016-12-10 18:29 ` Andrei Borzenkov
2016-12-10 19:50 ` Mark Otto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=584E7D26.7070002@oracle.com \
--to=stanislav.kholmanskikh@oracle.com \
--cc=grub-devel@gnu.org \
--cc=vasily.isaenko@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).