brcmfmac: check brcmf_bus_get_memdump result for error
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>
This commit is contained in:
parent
62e13097c4
commit
f4737a6203
|
@ -32,16 +32,25 @@ static int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
|
||||||
{
|
{
|
||||||
void *dump;
|
void *dump;
|
||||||
size_t ramsize;
|
size_t ramsize;
|
||||||
|
int err;
|
||||||
|
|
||||||
ramsize = brcmf_bus_get_ramsize(bus);
|
ramsize = brcmf_bus_get_ramsize(bus);
|
||||||
if (ramsize) {
|
if (!ramsize)
|
||||||
dump = vzalloc(len + ramsize);
|
return -ENOTSUPP;
|
||||||
if (!dump)
|
|
||||||
return -ENOMEM;
|
dump = vzalloc(len + ramsize);
|
||||||
memcpy(dump, data, len);
|
if (!dump)
|
||||||
brcmf_bus_get_memdump(bus, dump + len, ramsize);
|
return -ENOMEM;
|
||||||
dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL);
|
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue