Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Nov 2018 13:55:57 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r341229 - stable/12/stand/i386/libi386
Message-ID:  <201811291355.wATDtvEI047236@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Thu Nov 29 13:55:57 2018
New Revision: 341229
URL: https://svnweb.freebsd.org/changeset/base/341229

Log:
  MFC r340049:
  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:
  stable/12/stand/i386/libi386/biosdisk.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/i386/libi386/biosdisk.c
==============================================================================
--- stable/12/stand/i386/libi386/biosdisk.c	Thu Nov 29 13:54:07 2018	(r341228)
+++ stable/12/stand/i386/libi386/biosdisk.c	Thu Nov 29 13:55:57 2018	(r341229)
@@ -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;
@@ -489,6 +492,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);
 	}
 	if (BD(dev).bd_bcache == NULL)
 	    BD(dev).bd_bcache = bcache_allocate();
@@ -572,6 +577,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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811291355.wATDtvEI047236>