From owner-svn-src-head@freebsd.org Fri Nov 2 11:41:59 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4BAE210F33FA; Fri, 2 Nov 2018 11:41:59 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F3709845B3; Fri, 2 Nov 2018 11:41:58 +0000 (UTC) (envelope-from tsoome@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D5E89220F; Fri, 2 Nov 2018 11:41:58 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wA2BfwMu053020; Fri, 2 Nov 2018 11:41:58 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wA2BfwuU053019; Fri, 2 Nov 2018 11:41:58 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201811021141.wA2BfwuU053019@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Fri, 2 Nov 2018 11:41:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340049 - head/stand/i386/libi386 X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: head/stand/i386/libi386 X-SVN-Commit-Revision: 340049 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2018 11:41:59 -0000 Author: tsoome Date: Fri Nov 2 11:41:58 2018 New Revision: 340049 URL: https://svnweb.freebsd.org/changeset/base/340049 Log: loader: biosdisk should check if the media is present The bd_print/bd_open/bd_strategy need to make sure the device does have media, before getting into performing IO operations. Some systems can hung if the device without a media is accessed. Reported by: yuripv Modified: head/stand/i386/libi386/biosdisk.c Modified: head/stand/i386/libi386/biosdisk.c ============================================================================== --- head/stand/i386/libi386/biosdisk.c Fri Nov 2 10:18:56 2018 (r340048) +++ head/stand/i386/libi386/biosdisk.c Fri Nov 2 11:41:58 2018 (r340049) @@ -418,6 +418,9 @@ bd_print(int verbose) if ((ret = pager_output(line)) != 0) break; + if ((bdinfo[i].bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) + continue; + dev.dd.d_dev = &biosdisk; dev.dd.d_unit = i; dev.d_slice = -1; @@ -464,6 +467,8 @@ bd_open(struct open_file *f, ...) if ((BD(dev).bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) { if (!bd_int13probe(&BD(dev))) return (EIO); + if ((BD(dev).bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) + return (EIO); } BD(dev).bd_open++; if (BD(dev).bd_bcache == NULL) @@ -568,6 +573,9 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s size_t blks, blkoff, bsize, rest; caddr_t bbuf; int rc; + + if ((BD(dev).bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) + return (EIO); /* * First make sure the IO size is a multiple of 512 bytes. While we do