diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 292abf9..66b53a8 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -1618,7 +1618,7 @@ function wp_mkdir_p( $target ) {
 
 	// We need to find the permissions of the parent folder that exists and inherit that.
 	$target_parent = dirname( $target );
-	while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
+	while ( '.' != $target_parent && ! is_dir( $target_parent ) && @is_readable( $target_parent ) ) {
 		$target_parent = dirname( $target_parent );
 	}