From patchwork Mon Jan 30 15:09:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 9545583 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 550F1604A8 for ; Mon, 30 Jan 2017 15:10:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4848D20243 for ; Mon, 30 Jan 2017 15:10:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D19E2811E; Mon, 30 Jan 2017 15:10:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39E5E2679B for ; Mon, 30 Jan 2017 15:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753625AbdA3PKR (ORCPT ); Mon, 30 Jan 2017 10:10:17 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34101 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932111AbdA3PKO (ORCPT ); Mon, 30 Jan 2017 10:10:14 -0500 Received: by mail-lf0-f67.google.com with SMTP id q89so31607388lfi.1 for ; Mon, 30 Jan 2017 07:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XCYg/0pFxxmeD2zXKSvdXC8MHuZZkSClzU+4wLsit+s=; b=uOXk9s5I/m6yhKk+hIww/KMu3irxxMz/ZVKMukNwnUlNIMEiAfWvaZF2ksZsRKvQJS I8m0Asrwbvsl/V11G/6F17xYWeYp/mKOl9opaU4U/Rh6fnon+w04X2jRhAn5ZA039V5K fwYK6beXuzfak5s3/6cZZiA4lV6bSpIPaHaJjbdQbVu0PM5l/PJCyHWb9egUXyiS1AOV y66Uhs/8KUO3/207wkLUcj5mXIn5AehkwmtPwSM5l4nLvqD6six+5tk5Om1g77TGbRt/ IDOSArF6I/tFg5qInW0VE7TE9YLfDaAWeBb4gjeQBzbjr/DqjhNzf3lz6EmPutzZEmT9 n7kw== 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:mime-version :content-transfer-encoding; bh=XCYg/0pFxxmeD2zXKSvdXC8MHuZZkSClzU+4wLsit+s=; b=RYAinjxTefe7Kb0yYh8k3I8gSTLUc3mmew3w/qsJNrhN9Nv1EScWATmrmXbOEVahUv TdqjbcFvAMMR3OYevhVBPr7nUTpnLJR981K3UmlXcTRwv1spjwSpzoS1lyyZ0Tk+B1Vn Biuil8+C9pDn8ZOO/e5wF7AvzW/MKQHr9OBl0wfNrU9++XeIOUWJafMijR40WfYGZeYJ VHi5qbnYGvLok+SxG3F1M4/IQnAyqX9j1SGIp27osRYxuEPP2jaO5PHlkbyRNg6MxSgw 88HQjNJHsjyOMcwU8P9D2MbsjY5tNFLqpRQV3k/ivaCwku0wsi3+srMmsrg2DUPuy3c1 mWmA== X-Gm-Message-State: AIkVDXJa986uyeYiuITJYPmczZmyS44izmW2AWUcnrH0mnTAZDBtU6zOLMvSm3worhpOuw== X-Received: by 10.46.22.15 with SMTP id w15mr7635909ljd.35.1485789002544; Mon, 30 Jan 2017 07:10:02 -0800 (PST) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t126sm3786011lff.31.2017.01.30.07.10.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 07:10:01 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Kalle Valo Cc: Arend van Spriel , Franky Lin , Hante Meuleman , Pieter-Paul Giesberts , Franky Lin , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH 1/2] brcmfmac: check brcmf_bus_get_memdump result for error Date: Mon, 30 Jan 2017 16:09:51 +0100 Message-Id: <20170130150952.7133-1-zajec5@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- .../wireless/broadcom/brcm80211/brcmfmac/debug.c | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c index e64557c35553..6f8a4b074c31 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; }