Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2887110rwb; Mon, 15 Aug 2022 13:20:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR687qIv4f+nqpz3KCrP+c2AT+vL6jDkDjtdUIrCRj+eAETYCiKk937xzcFZ3NwmE67EzjNa X-Received: by 2002:a17:907:ea8:b0:731:67eb:b60a with SMTP id ho40-20020a1709070ea800b0073167ebb60amr11075854ejc.497.1660594697625; Mon, 15 Aug 2022 13:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594697; cv=none; d=google.com; s=arc-20160816; b=ojpyt+dBu55Wm6K4zE/fySmZaKjjApECud1PRBVl0SGOqNa07Gob8y7ce30nJyMBRG Qas8zhpacP1NAT0Ebf3NSz0Z4AYs2G13NBrjFnCunCQRkEN80Jl+sqgOIpVnTGODHAWw X1awjA+d0f5B1h6sx5w8wbb2HPi7Oo/2ny4+lXfQXSssj6NaN6cLXMrYemgNHJ/xT8Vj QTX+y8MvAOYRn6ckIlCrc95+5e9gxwwHJiP7Y4H6/IxmSKhWkoWzCt5wvDpaUWP7W/G0 RcWyEmnyqgj3sKKlwYurccPeGcEnqtFQU9hsZyhzHauMdGEdZrmCKkQ/bzZ8s5oWl9l2 Ljrg== 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=uE5S+7FThKz4nv/bGv/i7DqniibSnr1K8YOWY3JZeiQ=; b=KnlWdAoJ1AusqC8WZsSxoS4fihVocObcVzUeOzXjlar4F4gXS4RuFdL92UE/jLj+4Q oj5S+U4w2ThjQ9gxzTdV9NlUJLpVMOJCZGneAEJSOZC4vbVDXSRn3h1foo3xmJRkhZ5/ 6KgbtkmXR6MBCjP35eHYCijkImKEV/Cm80sW4PTD5VX/q1i4UAZh8llo14BATVZdvAJ5 8yEAs+/+mhUHlizyQeCxwK91I3yihN8dwfq9Fw5Dk7/wHIEE6dqlyE3AKXfV9brSDEYF f8WKY8PhXT901IKKfge9I/jCO+cZdiuFdEyqpj4+U8DDt9mayYKstXZOEdeeMHtaWdNw WzRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pxavnGOe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a170906720900b0072a7a1bd505si7414586ejk.207.2022.08.15.13.17.51; Mon, 15 Aug 2022 13:18:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pxavnGOe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1344271AbiHOTj0 (ORCPT + 99 others); Mon, 15 Aug 2022 15:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344343AbiHOTge (ORCPT ); Mon, 15 Aug 2022 15:36:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8107D642E2; Mon, 15 Aug 2022 11:45:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 832DA611EC; Mon, 15 Aug 2022 18:45:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BFECC433C1; Mon, 15 Aug 2022 18:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589157; bh=amYYCAHW3rWIpE80WiCKgqephSy5vPKtilzeKaE+CA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pxavnGOemPVFIJNNIyjhYF+lrAB7VhG01KDGxiaOaXtqrswTmwSUqcEVluUHLAPeq Yd+WsP+2JzbJ2fj5rj7uod1pN2VikgtBai757iRryPk5ILDet7oqUfxo2B97G8IJsb /2ZDlkU5lVSUPlx6qvZWdO82BN6caM9vq4zkqMJ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robin Murphy , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.15 600/779] swiotlb: fail map correctly with failed io_tlb_default_mem Date: Mon, 15 Aug 2022 20:04:04 +0200 Message-Id: <20220815180402.999454368@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robin Murphy [ Upstream commit c51ba246cb172c9e947dc6fb8868a1eaf0b2a913 ] In the failure case of trying to use a buffer which we'd previously failed to allocate, the "!mem" condition is no longer sufficient since io_tlb_default_mem became static and assigned by default. Update the condition to work as intended per the rest of that conversion. Fixes: 463e862ac63e ("swiotlb: Convert io_default_tlb_mem to static allocation") Signed-off-by: Robin Murphy Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- kernel/dma/swiotlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 2ee5419649ed..e62fb7a4da69 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -551,7 +551,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr, int index; phys_addr_t tlb_addr; - if (!mem) + if (!mem || !mem->nslabs) panic("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer"); if (mem_encrypt_active()) -- 2.35.1