Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3021343rwb; Mon, 15 Aug 2022 16:18:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Oo9pzlz3aTpCGynb9gluOQL00RkJKCY0jLaSRBu40D2tXOTEPgBX7WEQVl+qgB1fYH6x/ X-Received: by 2002:a17:902:e788:b0:16e:f924:6e41 with SMTP id cp8-20020a170902e78800b0016ef9246e41mr19269712plb.69.1660605517445; Mon, 15 Aug 2022 16:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605517; cv=none; d=google.com; s=arc-20160816; b=g3VuerDrV9S/5zd+rfTEYZUD3nHRa9Yw84uVAJ2LKJ8lzc44vq9K7Yf2i8Z3qDGNZp cXqjMUnTVdFodAB9EqOQ7xpmpVVYuGe2rTQ3HzpmqsCxKHpxU4riwz4SX52TW9cH/GNa wPJVn/1GgpLdWznQ2ieneA8mMa7+rrE3LS8+kpqU+6S5al44Z3sfUuwkbWYrAjhqgoAG dK8cxggKqimiYcfZucQixVxJgNwRyUMSsTZLIr5h/fsLiOIlpaiMC5jJlIta6gMOcc1K pReTWto7OMmVp6zeW5U8G/A4BTETcP86rmxl6vfWbhxzCeLi2zGNP/BUb7oPeR6eVris wTPA== 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=F4RCqFiqVjsyQu+FIGNQEvE2a0NelRlysvVBVWfg7t4=; b=Fqx3+/xmVqKYM5P13uQL3rtFYMREYB/eyA9r62bXJu34gymida0KpEPDJ/gsdhCLTF is6+QfEXwG/Innur/5ldpkbFwd6Flf4RmaNoL3WLJVEJCVsYzvxNCQ+b+rd/e1s7sseK y7ysJ8NHjPpl9S0hGGaH+/CF12L6J5U7SYruLDW5cvmyZRUTopdAxSLKRLoXlUuTRYlL ONpco+0TTWeyqjHSYJreI/EYGZdsv1MZsM3N5NTTw1eLmq+bHigiI5Uysb1Alivqk3GG qOOCagdTOPC8QGx/DCtrSbiuReKAxpgrH0AE+TfW32ShOQw8nP66PLefYx0ScfKY4XUs HymA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EFsfe9F0; 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 s6-20020a170902a50600b0016dcacb565csi10621376plq.596.2022.08.15.16.18.25; Mon, 15 Aug 2022 16:18:37 -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=EFsfe9F0; 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 S1351405AbiHOWmK (ORCPT + 99 others); Mon, 15 Aug 2022 18:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350912AbiHOWhT (ORCPT ); Mon, 15 Aug 2022 18:37:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFBE457278; Mon, 15 Aug 2022 12:50:37 -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 A93566125C; Mon, 15 Aug 2022 19:49:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60629C433D7; Mon, 15 Aug 2022 19:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592994; bh=UAcZmHsa1cU50LdsSO23W6xVAhxVJVOJgExFm4nAcdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EFsfe9F0xjALY+2FEGQ/SEeustdnKgjqjHSQyp5VvvOfv7GHHHFOFAGsU4vSWw9jS O7hrqf2PTcD/M+HgbKsr0FyXiLHpGA34c1xo5tb73kv/OwwYVaHDpK1MIt81b/bpN5 WBRefPyzSS9b426uti4nq3d8U7iMM4PgEQ33Pr2A= 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.18 0877/1095] swiotlb: fail map correctly with failed io_tlb_default_mem Date: Mon, 15 Aug 2022 20:04:36 +0200 Message-Id: <20220815180505.637602545@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 73a41cec9e38..90e5f5c92fdc 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -588,7 +588,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 (cc_platform_has(CC_ATTR_MEM_ENCRYPT)) -- 2.35.1