From owner-svn-src-head@freebsd.org Wed Oct 23 17:20:21 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 707A2158BCB; Wed, 23 Oct 2019 17:20:21 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46yxw52MW1z4NX4; Wed, 23 Oct 2019 17:20:21 +0000 (UTC) (envelope-from rstone@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 33CA427BED; Wed, 23 Oct 2019 17:20:21 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9NHKLV2051560; Wed, 23 Oct 2019 17:20:21 GMT (envelope-from rstone@FreeBSD.org) Received: (from rstone@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9NHKLFd051559; Wed, 23 Oct 2019 17:20:21 GMT (envelope-from rstone@FreeBSD.org) Message-Id: <201910231720.x9NHKLFd051559@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rstone set sender to rstone@FreeBSD.org using -f From: Ryan Stone Date: Wed, 23 Oct 2019 17:20:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353938 - head/sys/compat/linuxkpi/common/src X-SVN-Group: head X-SVN-Commit-Author: rstone X-SVN-Commit-Paths: head/sys/compat/linuxkpi/common/src X-SVN-Commit-Revision: 353938 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: Wed, 23 Oct 2019 17:20:21 -0000 Author: rstone Date: Wed Oct 23 17:20:20 2019 New Revision: 353938 URL: https://svnweb.freebsd.org/changeset/base/353938 Log: Add missing M_NOWAIT flag The LinuxKPI linux_dma code calls PCTRIE_INSERT with a mutex held, but does not set M_NOWAIT when allocating nodes, leading to a potential panic. All of this code can handle an allocation failure here, so prefer an allocation failure to sleeping on memory. Also fix a related case where NOWAIT/WAITOK was not specified. In this case it's not clear whether sleeping is allowed so be conservative and assume not. There are a lot of other paths in this code that can fail due to a lack of memory anyway. Differential Revision: https://reviews.freebsd.org/D22127 Reviewed by: imp Sponsored by: Dell EMC Isilon MFC After: 1 week Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_pci.c Wed Oct 23 17:02:45 2019 (r353937) +++ head/sys/compat/linuxkpi/common/src/linux_pci.c Wed Oct 23 17:20:20 2019 (r353938) @@ -500,7 +500,7 @@ static void * linux_dma_trie_alloc(struct pctrie *ptree) { - return (uma_zalloc(linux_dma_trie_zone, 0)); + return (uma_zalloc(linux_dma_trie_zone, M_NOWAIT)); } static void @@ -569,7 +569,10 @@ linux_dma_map_phys(struct device *dev, vm_paddr_t phys if (bus_dma_id_mapped(priv->dmat, phys, len)) return (phys); - obj = uma_zalloc(linux_dma_obj_zone, 0); + obj = uma_zalloc(linux_dma_obj_zone, M_NOWAIT); + if (obj == NULL) { + return (0); + } DMA_PRIV_LOCK(priv); if (bus_dmamap_create(priv->dmat, 0, &obj->dmamap) != 0) {