Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3718282pxv; Mon, 26 Jul 2021 10:09:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylitDM02EbRyn9j/DOYl6IYM4DGQv7+OiqwaS4Lgk4KOP73hkf3Ev51Zx4UwtYXa6c9T69 X-Received: by 2002:a05:600c:154d:: with SMTP id f13mr17900782wmg.3.1627319350506; Mon, 26 Jul 2021 10:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319350; cv=none; d=google.com; s=arc-20160816; b=GF4Ef6m2XrUR8FSIjtH0Cncpju4mWD3DfvD6Mpschou1lY+ht4vgGTBZ7yQcaOyaNV W7XtTJ6Qi+9MMQC0XpRkUqlPBs7LV29k6xa9jNgfn/4993ykVbg/bUXrrk+JdghwpJJh xTNzhCUfZfMQXlPi3EXV0CyTpe801W25ZDh2oc+SFErtbFj6Hx50WhQhHTVlHTWKDO7W HGJ7SIz/jpy0+1cJD1mNGl98pF3HHeR9HhEucrHembBkDlo5XROgV5twx5cAHjPYaIVH Hk8TxEFZLA0013s6TXiJnb+kBgLS+lBQmQOyhJau+Axwdu67AoZRuHPSYXuKCDmRS392 EUlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NmOSiMwfjSO4pHNkgvCthBOwYhFVpR12xmrPCy3FQOU=; b=Oq3ZWasuacwl4r0naBl2ZwJW8tEUyfqZAiQCp5rfhtsoZ+Itk3fN47NXkuatXZkncK X2BJq8Ilk7RuKD5cpV3LTzobYWAG3xH2TeSjLONizFa07c/h45CflMie1H4X3OvuPyON OoT55F9okgeO0RBKwjJjleNPbnjCPwXWDH6EMC28kBMPLP5tZ+pYhOeAWPNKs/zGNvo8 7P6YzV862NyeavavHpnuNDv4slVsNIT2fw3Yys8GAlGK4Vc9YAyTapJil6jFU8hqDh7T es8mEk4th9Iyo3+XFiQ+eIQunEasBrGGtnclNT0EhIs9lnjb8dLJp9zT6kdCg8dGe9LD X1+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OHfPH8zX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si351519wrv.8.2021.07.26.10.08.42; Mon, 26 Jul 2021 10:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OHfPH8zX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238500AbhGZPnN (ORCPT + 99 others); Mon, 26 Jul 2021 11:43:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:39526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237835AbhGZPYP (ORCPT ); Mon, 26 Jul 2021 11:24:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6873A60F38; Mon, 26 Jul 2021 16:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315482; bh=PotnVkL00huzlpfb7Bttwp0Mm9WjWG5f4iNsJZpXGoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OHfPH8zXxE1CYmNM/w7kcVWM6mw6ohR0PPmtvNztVbR4QSBUc9msW65yQ0mrEgpf8 wxRXx+AybUXbcGbjQZ8wltGt8Wi9Q9ERdQX5eJ6T/kaqPDTYUSpGp8Qpbl1DaHARRm akeacfxpoBZg7iRFOhpIvPsjqTJyJwYwv5UlHIKM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 5.10 115/167] ALSA: pcm: Fix mmap capability check Date: Mon, 26 Jul 2021 17:39:08 +0200 Message-Id: <20210726153843.262460079@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit c4824ae7db418aee6f50f308a20b832e58e997fd upstream. The hw_support_mmap() doesn't cover all memory allocation types and might use a wrong device pointer for checking the capability. Check the all memory allocation types more completely. Cc: Link: https://lore.kernel.org/r/20210720092640.12338-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/pcm_native.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -246,12 +246,18 @@ static bool hw_support_mmap(struct snd_p if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) return false; - if (substream->ops->mmap || - (substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV && - substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV_UC)) + if (substream->ops->mmap) return true; - return dma_can_mmap(substream->dma_buffer.dev.dev); + switch (substream->dma_buffer.dev.type) { + case SNDRV_DMA_TYPE_UNKNOWN: + return false; + case SNDRV_DMA_TYPE_CONTINUOUS: + case SNDRV_DMA_TYPE_VMALLOC: + return true; + default: + return dma_can_mmap(substream->dma_buffer.dev.dev); + } } static int constrain_mask_params(struct snd_pcm_substream *substream,