From patchwork Wed Apr 5 10:32:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96836 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp196605qgd; Wed, 5 Apr 2017 03:35:06 -0700 (PDT) X-Received: by 10.84.229.13 with SMTP id b13mr35045422plk.72.1491388506762; Wed, 05 Apr 2017 03:35:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si20203815pfi.300.2017.04.05.03.35.06; Wed, 05 Apr 2017 03:35:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933462AbdDEKea (ORCPT + 6 others); Wed, 5 Apr 2017 06:34:30 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:33937 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933482AbdDEKdZ (ORCPT ); Wed, 5 Apr 2017 06:33:25 -0400 Received: by mail-pg0-f50.google.com with SMTP id 21so6033870pgg.1 for ; Wed, 05 Apr 2017 03:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u90ti+p3dk2sh4ycOoEW1lyTgDHSsuGZudJ78Xag5TA=; b=hbO0DNym4+6LEZkZ3Bz/V6IeVo9mMQEMSwHZZbZhvq/AxzFJ0WRWTJahaKr0dbR2Pm HFc9udzLlHQPGLj2mZRzhw1ojHGPbDT+vCb2D3+f+iJd5iyvSliyaljjcRI4nL+XoxBx Ng3dNIYU9iW6qIdFHLhZ4PtdKZ3/DQUMz51r0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u90ti+p3dk2sh4ycOoEW1lyTgDHSsuGZudJ78Xag5TA=; b=OBe7MZgUJDHlzji/28xX2OQHvfKOm86aEoxJ0aUA9z1BYpJxPiUXrFZVQHgiNU6r03 RJL++NwpYO7w45JoX7HVIbNvO1PClKtpmz8MP1F9kH4X1SOwD4Nnc8wFtMjLjjEllK0W 2inThjua4dS5z6ir25RAenUUN3exAznJXuR3PqkY0Ng+MYPSVQEvDv1GjCTV3ip7Rqe7 wxy7m9VN6xmUOnQLOJYrUnYZEM1bYL2SkdDrybCg1pPAFh5DxoXFj3CqOenq/pR5Pxqg viAxbbshoG5h9OPfa11wfYuPJrMTfdLYLIkO+t++SAyi0FcpBkFDg6M3Q/HhHS1PeKyF nkxw== X-Gm-Message-State: AFeK/H2RmHbahlUHP+jzbNryDBoE9rsUDwk/fO0jrtyYZ/sR+JeQ1+0xkwsGCx3cFL1SFeBo X-Received: by 10.84.248.9 with SMTP id p9mr35219133pll.185.1491388397152; Wed, 05 Apr 2017 03:33:17 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id a62sm36732075pgc.60.2017.04.05.03.33.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Apr 2017 03:33:16 -0700 (PDT) From: Amit Pundir To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Kalle Valo Subject: [PATCH v2 for-4.9 23/32] brcmfmac: check brcmf_bus_get_memdump result for error Date: Wed, 5 Apr 2017 16:02:15 +0530 Message-Id: <1491388344-13521-24-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491388344-13521-1-git-send-email-amit.pundir@linaro.org> References: <1491388344-13521-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Rafał Miłecki This method may be unsupported (see: USB bus) or may just fail (see: SDIO bus). While at it rework logic in brcmf_sdio_bus_get_memdump function to avoid too many conditional code nesting levels. Signed-off-by: Rafał Miłecki Acked-by: Arend van Spriel Signed-off-by: Kalle Valo (cherry picked from commit f4737a62033d7f3e0db740c449fc62119da7ab8a) Signed-off-by: Amit Pundir --- .../wireless/broadcom/brcm80211/brcmfmac/debug.c | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c index e64557c..6f8a4b0 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c @@ -32,16 +32,25 @@ static int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, { void *dump; size_t ramsize; + int err; ramsize = brcmf_bus_get_ramsize(bus); - if (ramsize) { - dump = vzalloc(len + ramsize); - if (!dump) - return -ENOMEM; - memcpy(dump, data, len); - brcmf_bus_get_memdump(bus, dump + len, ramsize); - dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL); + if (!ramsize) + return -ENOTSUPP; + + dump = vzalloc(len + ramsize); + if (!dump) + return -ENOMEM; + + memcpy(dump, data, len); + err = brcmf_bus_get_memdump(bus, dump + len, ramsize); + if (err) { + vfree(dump); + return err; } + + dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL); + return 0; }