From patchwork Fri Dec 11 14:08:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 7830221 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 24E6ABEEE5 for ; Fri, 11 Dec 2015 14:09:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 418AC20524 for ; Fri, 11 Dec 2015 14:09:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1529320573 for ; Fri, 11 Dec 2015 14:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754026AbbLKOJF (ORCPT ); Fri, 11 Dec 2015 09:09:05 -0500 Received: from mail-qg0-f51.google.com ([209.85.192.51]:33924 "EHLO mail-qg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753156AbbLKOIq (ORCPT ); Fri, 11 Dec 2015 09:08:46 -0500 Received: by qgz52 with SMTP id 52so9088677qgz.1 for ; Fri, 11 Dec 2015 06:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bobcopeland-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=y3uOQEGvi0jO5/0CN7rb9U9A8BgA68CMiawOpneckcU=; b=YYydoXCIaFM7Qi1GOiEWmWwZNxlrUs4KH7g9ATpsi8l3s8F/VHszC9DHU5r+a6HpR1 i8rXBG24aIZf1964nHkcnChj5zxxP4q+D24RS75va+HoOtM1WA7oUCAb0Nsfzylx0dQY TS3u+N2pfExywlxCXDE87bbWVE68Qf1xi2NLw0X4boNxMVzwDQv0I/ClrADIooUbK32R z0/ekmPqcT/4+y+153kjvvQDvU3Ya/4BcGmWAIb6hfDrF9LQjYubJGnAmcBPDEZagqFu royie4Y7F2MKzODP9/FuJJeCGn3uLMKN7RVjD81dI3+S3iBRsT7tWnaJcoBXG2LnEURn lx9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=y3uOQEGvi0jO5/0CN7rb9U9A8BgA68CMiawOpneckcU=; b=JmGyvUUOtjuhl4F+TuEr9LwIUmvvfU19RMzQveeSIp0A3NIqBVicUTLaSHAV697TdX LyAQVHawDA5T67aQEyiKXTxqLlQCnWbxQWebBQC17A+S9Xm+0WKig1/gNa/YoLSz7Lio Oxq4nMdqYGaEV952eptKryYgUw1fZjEljZyTcdqkyqBWpywr+q3rnA9fUk2ZDzgIjf/s lrV4w4/Lag2AypcHPTNXZRQd1vU19loPLZhjtZZO1ENnSHfmHFtLvQ9lhFJsOxkQitVb Q6S0lZ5AiM6pOXEdubLS6Hsec79RB520ZASwbK5YzKubfeihe950Ryqzal794UkXffpT U17Q== X-Gm-Message-State: ALoCoQl2ZZPMwDUXwc5JcUvMOOK9PpaLJZQhmwA3x6CYXAgmb3RzNvxLBqD/cPIQ3rx35PUXPsSbx8RgUC6htQht0LoMUpSgrw== X-Received: by 10.140.18.115 with SMTP id 106mr24427917qge.34.1449842925458; Fri, 11 Dec 2015 06:08:45 -0800 (PST) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by smtp.gmail.com with ESMTPSA id n138sm8221061qhc.31.2015.12.11.06.08.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Dec 2015 06:08:44 -0800 (PST) Received: from bob by hash with local (Exim 4.84) (envelope-from ) id 1a7ON7-0002tE-NU; Fri, 11 Dec 2015 09:08:33 -0500 Date: Fri, 11 Dec 2015 09:08:33 -0500 From: Bob Copeland To: "fengwei.yin" Cc: linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org, k.eugene.e@gmail.com, bjorn.andersson@sonymobile.com, lking@qti.qualcomm.com Subject: Re: [PATCH] wcn36xx: handle rx skb allocation failure to avoid system crash Message-ID: <20151211140833.GA22332@localhost> References: <1449034051-12536-1-git-send-email-fengwei.yin@linaro.org> <566ACC1C.1070304@linaro.org> <20151211133730.GA8835@localhost> <566AD356.50404@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <566AD356.50404@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Dec 11, 2015 at 09:44:54PM +0800, fengwei.yin wrote: > > /* skip this frame if we can't alloc a new rx buffer */ > > if (ret) > > goto drop; > This can't work because we need to initialize the DMA for the old skb again. > Which is done in following > switch (ch->ch_type) { > block. Hmm, good point. You could still move that out to a function like this: ...that said, not really sure it's worth it now that the 'goto' is only skipping two lines. So, I would be ok with the original patch too. diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index f8dfa05..fd447bf 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -467,6 +467,27 @@ out_err: } +/* or whatever name makes sense... */ +static void wcn36xx_restart_dma(struct wcn36xx *wcn, + struct wcn36xx_dxe_ch *ch, + struct wcn36xx_dxe_desc *dxe) +{ + switch (ch->ch_type) { + case WCN36XX_DXE_CH_RX_L: + dxe->ctrl = WCN36XX_DXE_CTRL_RX_L; + wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_ENCH_ADDR, + WCN36XX_DXE_INT_CH1_MASK); + break; + case WCN36XX_DXE_CH_RX_H: + dxe->ctrl = WCN36XX_DXE_CTRL_RX_H; + wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_ENCH_ADDR, + WCN36XX_DXE_INT_CH3_MASK); + break; + default: + wcn36xx_warn("Unknown channel\n"); + } +} + static int wcn36xx_rx_handle_packets(struct wcn36xx *wcn, struct wcn36xx_dxe_ch *ch) { @@ -478,26 +499,18 @@ static int wcn36xx_rx_handle_packets(struct wcn36xx *wcn, while (!(dxe->ctrl & WCN36XX_DXE_CTRL_VALID_MASK)) { skb = ctl->skb; dma_addr = dxe->dst_addr_l; - wcn36xx_dxe_fill_skb(wcn->dev, ctl); + ret = wcn36xx_dxe_fill_skb(wcn->dev, ctl); - switch (ch->ch_type) { - case WCN36XX_DXE_CH_RX_L: - dxe->ctrl = WCN36XX_DXE_CTRL_RX_L; - wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_ENCH_ADDR, - WCN36XX_DXE_INT_CH1_MASK); - break; - case WCN36XX_DXE_CH_RX_H: - dxe->ctrl = WCN36XX_DXE_CTRL_RX_H; - wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_ENCH_ADDR, - WCN36XX_DXE_INT_CH3_MASK); - break; - default: - wcn36xx_warn("Unknown channel\n"); - } + /* skip this frame in OOM condition */ + if (ret) + goto drop; dma_unmap_single(wcn->dev, dma_addr, WCN36XX_PKT_SIZE, DMA_FROM_DEVICE); wcn36xx_rx_skb(wcn, skb); + +drop: + wcn36xx_restart_dma(wcn, ch, dxe); ctl = ctl->next; dxe = ctl->desc; }