]> git.ipfire.org Git - thirdparty/grub.git/commit
efinet: Correct closing of SNP protocol
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 29 Nov 2021 15:00:28 +0000 (16:00 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 23 Dec 2021 00:22:40 +0000 (01:22 +0100)
commitefd9406e12df2b66e6704bad0ce3225aa3051c0e
treed7485894572d1336fb703b87f6a782fb68a2719e
parentbd3322cd18105d8b852b8997d4606abe8dac5ff1
efinet: Correct closing of SNP protocol

In the context of the implementation of the EFI_LOAD_FILE2_PROTOCOL for
the initial ramdisk it was observed that opening the SNP protocol failed.
https://lists.gnu.org/archive/html/grub-devel/2021-10/msg00020.html
This is due to an incorrect call to CloseProtocol().

The first parameter of CloseProtocol() is the handle, not the interface.

We call OpenProtocol() with ControllerHandle == NULL. Hence we must also
call CloseProtcol() with ControllerHandel == NULL.

Each call of OpenProtocol() for the same network card handle is expected to
return the same interface pointer. If we want to close the protocol which
we opened non-exclusively when searching for a card, we have to do this
before opening the protocol exclusively.

As there is no guarantee that we successfully open the protocol add checks
in the transmit and receive functions.

Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/net/drivers/efi/efinet.c