From owner-svn-src-all@freebsd.org Thu May 26 23:08:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEE39B47C90; Thu, 26 May 2016 23:08:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BF58B16B5; Thu, 26 May 2016 23:08:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4QN8vTe065728; Thu, 26 May 2016 23:08:57 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4QN8vc3065727; Thu, 26 May 2016 23:08:57 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201605262308.u4QN8vc3065727@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 26 May 2016 23:08:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300791 - head/sys/boot/efi/libefi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 23:08:59 -0000 Author: jhb Date: Thu May 26 23:08:57 2016 New Revision: 300791 URL: https://svnweb.freebsd.org/changeset/base/300791 Log: Use a unique error message if we fail to find the simple network protocol. While here, fix the various net driver callbacks to return early instead of crashing if this fails. (The 'init' callback from the netif interface doesn't return an error if the protocol lookup fails.) Sponsored by: Cisco Systems Modified: head/sys/boot/efi/libefi/efinet.c Modified: head/sys/boot/efi/libefi/efinet.c ============================================================================== --- head/sys/boot/efi/libefi/efinet.c Thu May 26 23:07:20 2016 (r300790) +++ head/sys/boot/efi/libefi/efinet.c Thu May 26 23:08:57 2016 (r300791) @@ -122,6 +122,8 @@ efinet_put(struct iodesc *desc, void *pk void *buf; net = nif->nif_devdata; + if (net == NULL) + return (-1); status = net->Transmit(net, 0, len, pkt, 0, 0, 0); if (status != EFI_SUCCESS) @@ -152,6 +154,8 @@ efinet_get(struct iodesc *desc, void *pk char buf[2048]; net = nif->nif_devdata; + if (net == NULL) + return (0); t = time(0); while ((time(0) - t) < timeout) { @@ -192,7 +196,7 @@ efinet_init(struct iodesc *desc, void *m h = nif->nif_driver->netif_ifs[nif->nif_unit].dif_private; status = BS->HandleProtocol(h, &sn_guid, (VOID **)&nif->nif_devdata); if (status != EFI_SUCCESS) { - printf("net%d: cannot start interface (status=%lu)\n", + printf("net%d: cannot fetch interface data (status=%lu)\n", nif->nif_unit, EFI_ERROR_CODE(status)); return; } @@ -241,6 +245,9 @@ efinet_end(struct netif *nif) { EFI_SIMPLE_NETWORK *net = nif->nif_devdata; + if (net == NULL) + return; + net->Shutdown(net); }