Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3092364rwb; Mon, 15 Aug 2022 17:56:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7qlf8ecWp9pWy4TtfNbK1WK3IDFI6L1gY7CrporBYLlkO9vZN7d2vTQCI8K30lukSgBDcB X-Received: by 2002:a05:6402:d06:b0:440:3e9d:77d with SMTP id eb6-20020a0564020d0600b004403e9d077dmr15858998edb.286.1660611394239; Mon, 15 Aug 2022 17:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611394; cv=none; d=google.com; s=arc-20160816; b=us3nq6f+7FHWzbj2DE57xmlYTlXsTmijGEIAQfr6yx+9Rwa2fakLXMTWUTOI+fTN2X HpuV61dHDUDARgK2WEQnWaUeVZGVl7pTxwOgWC2Xi0R2IwP935Zrb8IijjF4fzp5Wm/o onRvErzuDDU/bf04OiepAyXQN5BgC977cF3V839tckGWeMQWexqyWhNtZ0vsi0VM4XfS JvzSknRmLwB2qqwfZuTlIVVOrTM/q8eXqdpNy1iEVWpEFykrwSKw9SojVCiWUYYmwO6h CMsUpbQ5q2moxdLWqJXrB5AA8HsUCKR7u+HspzSr3PGaJRibFQdDAEfmAUi0IzxMkVqK 89Ew== 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=loPxupgtSSZUX9yokeWuPnV0mv0kNCXv6N75tw3v7zU=; b=P/6n7o5ppWlqHCQhIj2sq+MST1Vg170shfUWPBAfK44LQhz8JBOMZ8Kb5IKx9qhagW m7dTCXfZsOX/lBhGOvsKR8cKOZdOt2c7BG6BUymmVEoqXu7oMbGwcm0I96+DjSs010mP LXWedkGx7xmGPBPT/ueOLje1ltSA8FcYBlnh8jiifs/vg/opjUTu/9OLZYFvugRLhUIj VJiqGLQ4Zn+3glUhTbs9DfX4YEeIQl+jRw3HrSNp1bgKcba+eyJXOsd4d5UmqMMGT76f IsMrkXF79UrcInMxf9Y5Db8N7do/fENj6CAJjeQ0a9BVtB1NED5fjqKTu4CX38+vG+Sg Va8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jy1K5d/B"; 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 v3-20020a509543000000b0044301c6aca9si8730355eda.379.2022.08.15.17.56.07; Mon, 15 Aug 2022 17:56:34 -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="jy1K5d/B"; 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 S244936AbiHPArB (ORCPT + 99 others); Mon, 15 Aug 2022 20:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245146AbiHPAnv (ORCPT ); Mon, 15 Aug 2022 20:43:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB7ED41B6; Mon, 15 Aug 2022 13:40:24 -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 ams.source.kernel.org (Postfix) with ESMTPS id DBAE2B8113E; Mon, 15 Aug 2022 20:40:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFFE0C433C1; Mon, 15 Aug 2022 20:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596021; bh=2TB88MHsu1Xh+jypbMXWSsaOFWNOriUCzj5MZUghOAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jy1K5d/BSZm5WQBG7ZL+PLnupo2c3QOkcnunrFkOkp/c033bLp1jYLp59qJbXF0It 56zqP/An9gk16atD854Ze0OdFBmS76usc3hPwQQKt7B4p7BSDBMFA9xFb+4op1S0cQ Oy+tBXFiTKblhYvSB6b95wGg4E32Bfu+BLTJPvVQ= 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.19 0949/1157] swiotlb: fail map correctly with failed io_tlb_default_mem Date: Mon, 15 Aug 2022 20:05:05 +0200 Message-Id: <20220815180517.523648968@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 cb50f8d38360..5830dce6081b 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -580,7 +580,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