Received: by 10.192.165.148 with SMTP id m20csp3747248imm; Mon, 30 Apr 2018 05:51:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoFSMbtY5iHkGjaxJG2zrivqzCA/rQC8j0+LQ4zbf8V/1hiNRn1riUzbZd57Q+u+9sWW05n X-Received: by 2002:a65:6645:: with SMTP id z5-v6mr6021052pgv.43.1525092688483; Mon, 30 Apr 2018 05:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525092688; cv=none; d=google.com; s=arc-20160816; b=ZroqKJ2M1k8SFwqmalOo3j2JZ55kM6egLiS2mtn4TnnZt7VZTrEPwuTUvflO9RujAI rMzab35hziI3eg681fVUkvWGpbIXI91xKkatLsMRvrC21tyCFg4p2hSn5l/IaqWjPEaL 5R5uQRI5qmNCGcQbkYGEr+9t/Ad/kSHjAC3KdEY6q/uBidtVnpoFglzgKb5y4yZNeDMh y3zjAbxD0HO0i42A9ZEt35VtX9Ukjbg4gP5tMcUseWNlmVg++muw466SomRYdmunNMTb RdRZx7xRaTFVzVtYk2AbZ8rslkZPjv3tEJN8d5bBesE25jmQ6GMUBhN5pHo0BjLOVztL xD8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=BqR7QfhY6Mi4oupWnnwUnQ/yLumBQc8B9UgagWBb+dA=; b=tYLkRIgrUlBlvVCNrFdgc6It6cK+Y3tuEr+IXqxQVmU+kXDSz0zYNY7/VD7kMzwqEg qksmWuy9xS/ea6dfGTpLAO4DVxQv/dLDJxh2QfEd+Wt1oqsVafT6gnYzgXwTVVR8tpq7 QMVNl/EMbgkpLRCKqUaHrFScM251S7X347lfNDy0on3CmzfqCnpU/NlIqokwjwz/OUqW E34MZuKAL2y9679sfHcMQB8C1f+hZ8IJhmqIp8pqWpeJP6cCqEOWB7Xcvkys43ELVWgn gHcE8KvqczOX8bevhB/Vz0rMd71nlqXYNPRsCmaF4m5wk/c5+qqjb6Q4V2azVhDyiQKD Wx0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 p10-v6si6130133pgs.432.2018.04.30.05.51.05; Mon, 30 Apr 2018 05:51:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753256AbeD3Mup (ORCPT + 99 others); Mon, 30 Apr 2018 08:50:45 -0400 Received: from gateway24.websitewelcome.com ([192.185.51.122]:25834 "EHLO gateway24.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752959AbeD3Muo (ORCPT ); Mon, 30 Apr 2018 08:50:44 -0400 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 56B9CA03FE for ; Mon, 30 Apr 2018 07:50:43 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id D8GRfn2dvWCOCD8GRfgiAa; Mon, 30 Apr 2018 07:50:43 -0500 X-Authority-Reason: nr=8 Received: from [187.172.56.86] (port=60019 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1fD8GQ-001tA1-NB; Mon, 30 Apr 2018 07:50:42 -0500 Date: Mon, 30 Apr 2018 07:50:40 -0500 From: "Gustavo A. R. Silva" To: Ajay Singh , Ganesh Krishna , Greg Kroah-Hartman Cc: linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access Message-ID: <20180430125040.GA19050@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.172.56.86 X-Source-L: No X-Exim-ID: 1fD8GQ-001tA1-NB X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [187.172.56.86]:60019 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 6 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If i < slot_id is initially true then it will remain true. Also, as i is being decremented it will end up accessing memory out of bounds. Fix this by incrementing *i* instead of decrementing it. Addresses-Coverity-ID: 1468454 ("Infinite loop") Fixes: faa657641081 ("staging: wilc1000: refactor scan() to free kmalloc memory on failure cases") Signed-off-by: Gustavo A. R. Silva --- BTW... at first sight it seems to me that variables slot_id and i should be of type unsigned instead of signed. drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 3ca0c97..67104e8 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -608,7 +608,7 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request *request, out_free: - for (i = 0; i < slot_id ; i--) + for (i = 0; i < slot_id; i++) kfree(ntwk->net_info[i].ssid); kfree(ntwk->net_info); -- 2.7.4