brcmfmac: check brcmf_bus_get_memdump result for error
authorRafał Miłecki <rafal@milecki.pl>
Mon, 30 Jan 2017 15:09:51 +0000 (16:09 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 2 Feb 2017 06:14:25 +0000 (08:14 +0200)
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 <rafal@milecki.pl>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c

index e64557c35553fe4a53a933196d923902cb989270..6f8a4b074c312155bd3873804dd91eeea828cfd2 100644 (file)
@@ -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;
 }