diff --git a/hif/src/ath_procfs.c b/hif/src/ath_procfs.c index e014f2a2ae..2fb2b1d5af 100644 --- a/hif/src/ath_procfs.c +++ b/hif/src/ath_procfs.c @@ -72,10 +72,8 @@ static ssize_t ath_procfs_diag_read(struct file *file, char __user *buf, return -EINVAL; read_buffer = qdf_mem_malloc(count); - if (NULL == read_buffer) { - HIF_ERROR("%s: cdf_mem_alloc failed", __func__); + if (!read_buffer) return -ENOMEM; - } HIF_DBG("rd buff 0x%pK cnt %zu offset 0x%x buf 0x%pK", read_buffer, count, (int)*pos, buf); @@ -141,10 +139,9 @@ static ssize_t ath_procfs_diag_write(struct file *file, return -EINVAL; write_buffer = qdf_mem_malloc(count); - if (NULL == write_buffer) { - HIF_ERROR("%s: cdf_mem_alloc failed", __func__); + if (!write_buffer) return -ENOMEM; - } + if (copy_from_user(write_buffer, buf, count)) { qdf_mem_free(write_buffer); HIF_ERROR("%s: copy_to_user error in /proc/%s", diff --git a/hif/src/ce/ce_bmi.c b/hif/src/ce/ce_bmi.c index 2e4ba8651f..019c03ec1d 100644 --- a/hif/src/ce/ce_bmi.c +++ b/hif/src/ce/ce_bmi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -149,10 +149,9 @@ QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *hif_ctx, transaction = (struct BMI_transaction *)qdf_mem_malloc(sizeof(*transaction)); - if (unlikely(!transaction)) { - HIF_ERROR("%s: no memory", __func__); + if (unlikely(!transaction)) return QDF_STATUS_E_NOMEM; - } + transaction_id = (mux_id & MUX_ID_MASK) | (transaction_id & TRANSACTION_ID_MASK); #ifdef QCA_WIFI_3_0 diff --git a/hif/src/ce/ce_main.c b/hif/src/ce/ce_main.c index 6389bac4d9..be818967d8 100644 --- a/hif/src/ce/ce_main.c +++ b/hif/src/ce/ce_main.c @@ -1424,10 +1424,9 @@ struct CE_handle *ce_init(struct hif_softc *scn, if (!CE_state) { CE_state = (struct CE_state *)qdf_mem_malloc(sizeof(*CE_state)); - if (!CE_state) { - HIF_ERROR("%s: CE_state has no mem", __func__); + if (!CE_state) return NULL; - } + malloc_CE_state = true; qdf_spinlock_create(&CE_state->ce_index_lock); @@ -1492,11 +1491,9 @@ struct CE_handle *ce_init(struct hif_softc *scn, qdf_mem_malloc(nentries * sizeof(struct CE_src_desc) + CE_DESC_RING_ALIGN); - if (src_ring->shadow_base_unaligned == NULL) { - HIF_ERROR("%s: src ring no shadow_base mem", - __func__); + if (!src_ring->shadow_base_unaligned) goto error_no_dma_mem; - } + src_ring->shadow_base = (struct CE_src_desc *) (((size_t) src_ring->shadow_base_unaligned + CE_DESC_RING_ALIGN - 1) & diff --git a/hif/src/hif_napi.c b/hif/src/hif_napi.c index b1079b9fa6..0539dc871f 100644 --- a/hif/src/hif_napi.c +++ b/hif/src/hif_napi.c @@ -181,7 +181,6 @@ int hif_napi_create(struct hif_opaque_softc *hif_ctx, napii = qdf_mem_malloc(sizeof(*napii)); napid->napis[i] = napii; if (!napii) { - NAPI_DEBUG("NAPI alloc failure %d", i); rc = -ENOMEM; goto napii_free; } diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c index 14df72a9a5..f7d65d10be 100644 --- a/hif/src/pcie/if_pci.c +++ b/hif/src/pcie/if_pci.c @@ -4261,11 +4261,8 @@ int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name) HIF_INFO("Initializing Runtime PM wakelock %s", name); context = qdf_mem_malloc(sizeof(*context)); - if (!context) { - HIF_ERROR("%s: No memory for Runtime PM wakelock context", - __func__); + if (!context) return -ENOMEM; - } context->name = name ? name : "Default"; lock->lock = context; diff --git a/hif/src/sdio/native_sdio/src/hif.c b/hif/src/sdio/native_sdio/src/hif.c index 875e3de3ab..ad31219cd8 100644 --- a/hif/src/sdio/native_sdio/src/hif.c +++ b/hif/src/sdio/native_sdio/src/hif.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1416,16 +1416,14 @@ static struct hif_sdio_dev *add_hif_device(struct sdio_func *func) hifdevice = (struct hif_sdio_dev *) qdf_mem_malloc(sizeof( struct hif_sdio_dev)); AR_DEBUG_ASSERT(hifdevice != NULL); - if (hifdevice == NULL) { - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("Alloc hif device fail\n")); + if (!hifdevice) return NULL; - } + #if HIF_USE_DMA_BOUNCE_BUFFER hifdevice->dma_buffer = qdf_mem_malloc(HIF_DMA_BUFFER_SIZE); AR_DEBUG_ASSERT(hifdevice->dma_buffer != NULL); if (hifdevice->dma_buffer == NULL) { qdf_mem_free(hifdevice); - AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("Alloc dma buffer fail\n")); return NULL; } #endif diff --git a/hif/src/sdio/transfer/transfer.c b/hif/src/sdio/transfer/transfer.c index 3c65b378c7..c665ac7e8d 100644 --- a/hif/src/sdio/transfer/transfer.c +++ b/hif/src/sdio/transfer/transfer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * * @@ -130,13 +130,10 @@ QDF_STATUS hif_dev_send_buffer(struct hif_sdio_device *pdev, uint32_t xfer_id, } else { sctx = (struct hif_sendContext *)qdf_mem_malloc(sizeof(*sctx) + padded_length); - if (sctx) { + if (sctx) sctx->bNewAlloc = true; - } else { - HIF_ERROR("%s: Alloc send context fail %zu\n", - __func__, sizeof(*sctx) + padded_length); + else return QDF_STATUS_E_NOMEM; - } } sctx->netbuf = buf; diff --git a/hif/src/usb/hif_usb.c b/hif/src/usb/hif_usb.c index ad906cf7ab..952358018f 100644 --- a/hif/src/usb/hif_usb.c +++ b/hif/src/usb/hif_usb.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -175,8 +175,7 @@ static QDF_STATUS hif_send_internal(struct HIF_DEVICE_USB *hif_usb_device, send_context = qdf_mem_malloc(sizeof(struct hif_usb_send_context) + head_data_len + nbytes); - if (send_context == NULL) { - HIF_ERROR("%s: qdf_mem_malloc failed", __func__); + if (!send_context) { status = QDF_STATUS_E_NOMEM; goto err; } diff --git a/hif/src/usb/if_usb.c b/hif/src/usb/if_usb.c index 36a23c3a89..d727a036a2 100644 --- a/hif/src/usb/if_usb.c +++ b/hif/src/usb/if_usb.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -634,10 +634,9 @@ void hif_fw_assert_ramdump_pattern(struct hif_usb_softc *sc) sc->ramdump[i] = qdf_mem_malloc(sizeof(struct fw_ramdump) + fw_ram_reg_size[i]); - if (!sc->ramdump[i]) { - pr_err("Fail to allocate memory for ram dump"); + if (!sc->ramdump[i]) QDF_BUG(0); - } + (sc->ramdump[i])->mem = (uint8_t *) (sc->ramdump[i] + 1); fw_ram_seg_addr[i] = (sc->ramdump[i])->mem; HIF_ERROR("FW %s start addr = %#08x\n", diff --git a/hif/src/usb/usbdrv.c b/hif/src/usb/usbdrv.c index 0ad734a347..028c0dfa98 100644 --- a/hif/src/usb/usbdrv.c +++ b/hif/src/usb/usbdrv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -151,15 +151,14 @@ static QDF_STATUS usb_hif_alloc_pipe_resources for (i = 0; i < urb_cnt; i++) { urb_context = qdf_mem_malloc(sizeof(*urb_context)); - if (NULL == urb_context) { + if (!urb_context) { status = QDF_STATUS_E_NOMEM; - HIF_ERROR("urb_context is null"); break; } urb_context->pipe = pipe; urb_context->urb = usb_alloc_urb(0, GFP_KERNEL); - if (NULL == urb_context->urb) { + if (!urb_context->urb) { status = QDF_STATUS_E_NOMEM; qdf_mem_free(urb_context); HIF_ERROR("urb_context->urb is null"); diff --git a/htc/htc.c b/htc/htc.c index 98e9e45bcd..a1f30e883b 100644 --- a/htc/htc.c +++ b/htc/htc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -61,7 +61,6 @@ static void destroy_htc_tx_ctrl_packet(HTC_PACKET *pPacket) qdf_nbuf_t netbuf; netbuf = (qdf_nbuf_t) GET_HTC_PACKET_NET_BUF_CONTEXT(pPacket); - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("free ctrl netbuf :0x%pK\n", netbuf)); if (netbuf != NULL) qdf_nbuf_free(netbuf); qdf_mem_free(pPacket); @@ -81,11 +80,8 @@ static HTC_PACKET *build_htc_tx_ctrl_packet(qdf_device_t osdev) if (NULL == netbuf) { qdf_mem_free(pPacket); pPacket = NULL; - qdf_print("%s: nbuf alloc failed", __func__); break; } - AR_DEBUG_PRINTF(ATH_DEBUG_TRC, - ("alloc ctrl netbuf :0x%pK\n", netbuf)); SET_HTC_PACKET_NET_BUF_CONTEXT(pPacket, netbuf); } while (false); @@ -268,10 +264,8 @@ HTC_HANDLE htc_create(void *ol_sc, struct htc_init_info *pInfo, A_REGISTER_MODULE_DEBUG_INFO(htc); target = (HTC_TARGET *) qdf_mem_malloc(sizeof(HTC_TARGET)); - if (target == NULL) { - HTC_ERROR("%s: Unable to allocate memory", __func__); + if (!target) return NULL; - } htc_runtime_pm_init(target); htc_credit_history_init();