Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3099306ybl; Fri, 20 Dec 2019 03:59:07 -0800 (PST) X-Google-Smtp-Source: APXvYqw249cL+Uq2Tizxn/NSCnFDwUiH13lA9SiJsAqUAqvh2mmtfQOX+UbI18cuzPPLn6eNm4+C X-Received: by 2002:a05:6830:1e37:: with SMTP id t23mr14747636otr.16.1576843147768; Fri, 20 Dec 2019 03:59:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576843147; cv=none; d=google.com; s=arc-20160816; b=ftFAH/vRs7NBXqhIHLqsYg+QbhJx+U7546ILXVFwdN4+s6kV4EYK1F32OkGG2bFViE L0TW0gJ/U4tMjb+2xQjISQhs1n5tMFGFotXUt5WDEOf0H3uayyLaHsXv73N/dqqyLwgU U2zhXG86GA01LLNuNPw/ejJWeO0gd9nj3ENTig7L6Hn/8puFBoemv6f3ewkzRU8nHAzd PcpWLUpOxUygSDbyyC3GS5GHSgEgC1tE6jrhUvok5sHU2Zcp0kybWem/BfFEcJvRFB/J qhBBPBsLZFtFY2gQ8om1BZcjGgcZALwR7ZQlRlsrcoj//hWepI14CVd2Dsh2vL7v2hlO o3Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=ofOOsqqYUkt3Abevu69Wy+NDx+4TPMQgKBA+l22rATs=; b=Nk4Ix7QYewQi7Kj5d4b8EMxxF0geba1vFb/B5yvgD1/5jCt2OuscVzEh9SrintQC5M baymkfqOZUikThnJlw4Y4GulA/dp24fLE3CMlefOPz39AKM9Nz77TCpxtq2LvAvFnuo8 d19wrqg6hEgPiPtaE7FJ1KGAkOEFMdcLQDVmmZXQgsWy7zaCO5yNwgm2Oa5xh9JnTaBO Ri5RH88Zblw7yexgVPA6HB3ttRXEOeAGtdWv7pxo0BG5LE4Tak4QmGQJ3jmjs09HCZ8Q irN4wKlWrF2BNRFHX1NgRo7ylHVie6qbEe0MGmGCAxLNvYuYIwySginMBad95YktBDTb Zv1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b25si4523071otp.212.2019.12.20.03.58.58; Fri, 20 Dec 2019 03:59:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727384AbfLTL4v (ORCPT + 99 others); Fri, 20 Dec 2019 06:56:51 -0500 Received: from paleale.coelho.fi ([176.9.41.70]:53986 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727177AbfLTL4v (ORCPT ); Fri, 20 Dec 2019 06:56:51 -0500 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.92.2) (envelope-from ) id 1iiGtl-0007ip-62; Fri, 20 Dec 2019 13:56:49 +0200 From: Luca Coelho To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org Date: Fri, 20 Dec 2019 13:56:34 +0200 Message-Id: <20191220115638.1299888-7-luca@coelho.fi> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191220115638.1299888-1-luca@coelho.fi> References: <20191220115638.1299888-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Subject: [PATCH v5.5 06/10] iwlwifi: fix TLV fragment allocation loop Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Luca Coelho In the allocation loop, "pages" will never become zero (because of the DIV_ROUND_UP), so if we can't allocate any size and pages becomes 1, we will keep trying to allocate 1 page until it succeeds. And in that case, as coverity reported, block will never be NULL. Reported-by: coverity-bot Addresses-Coverity-ID: 1487402 ("Control flow issues") Fixes: 14124b25780d ("iwlwifi: dbg_ini: implement monitor allocation flow") Signed-off-by: Luca Coelho Fixes: 14124b25780d ("iwlwifi: dbg_ini: implement monitor allocation flow") Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c index f266647dc08c..ce8f248c33ea 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c @@ -480,7 +480,14 @@ static int iwl_dbg_tlv_alloc_fragment(struct iwl_fw_runtime *fwrt, if (!frag || frag->size || !pages) return -EIO; - while (pages) { + /* + * We try to allocate as many pages as we can, starting with + * the requested amount and going down until we can allocate + * something. Because of DIV_ROUND_UP(), pages will never go + * down to 0 and stop the loop, so stop when pages reaches 1, + * which is too small anyway. + */ + while (pages > 1) { block = dma_alloc_coherent(fwrt->dev, pages * PAGE_SIZE, &physical, GFP_KERNEL | __GFP_NOWARN); -- 2.24.0