summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDustin Brown <dustinb@codeaurora.org>2018-01-04 11:06:23 -0800
committersnandini <snandini@codeaurora.org>2018-01-08 11:47:14 -0800
commit4e887a6e0a74ebf50b9eb672b9915439fdfb7d5c (patch)
tree91a90c25753b0c15fffaf2e7b3d34f12fcf1bf69
parentcba67ba550d567acd0941bdde132d6ed3ce9919b (diff)
qcacmn: Return error on nbuf map alloc failure
When nbuf map/unmap tracking is enabled, a small metadata structure is allocated to keep the tracking information. In cases where this allocation fails during the map operation, return an error status instead of mapping the nbuf. This prevents a false positive unmap-never-mapped panic when the nbuf is unmapped. Change-Id: Id01c1f61165a0beff4edd6cc6a0a2fc5f64d9b04 CRs-Fixed: 2167082
-rw-r--r--qdf/linux/src/qdf_nbuf.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/qdf/linux/src/qdf_nbuf.c b/qdf/linux/src/qdf_nbuf.c
index 6f18e36c4f94..3705396c6368 100644
--- a/qdf/linux/src/qdf_nbuf.c
+++ b/qdf/linux/src/qdf_nbuf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -430,7 +430,7 @@ static struct qdf_nbuf_map_metadata *qdf_nbuf_meta_get(qdf_nbuf_t nbuf)
return NULL;
}
-static void
+static QDF_STATUS
qdf_nbuf_track_map(qdf_nbuf_t nbuf, const char *file, uint32_t line)
{
struct qdf_nbuf_map_metadata *meta;
@@ -438,7 +438,7 @@ qdf_nbuf_track_map(qdf_nbuf_t nbuf, const char *file, uint32_t line)
QDF_BUG(nbuf);
if (!nbuf) {
qdf_err("Cannot map null nbuf");
- return;
+ return QDF_STATUS_E_INVAL;
}
qdf_spin_lock_irqsave(&qdf_nbuf_map_lock);
@@ -451,7 +451,7 @@ qdf_nbuf_track_map(qdf_nbuf_t nbuf, const char *file, uint32_t line)
meta = qdf_mem_malloc(sizeof(*meta));
if (!meta) {
qdf_err("Failed to allocate nbuf map tracking metadata");
- return;
+ return QDF_STATUS_E_NOMEM;
}
meta->nbuf = nbuf;
@@ -461,6 +461,8 @@ qdf_nbuf_track_map(qdf_nbuf_t nbuf, const char *file, uint32_t line)
qdf_spin_lock_irqsave(&qdf_nbuf_map_lock);
hash_add(qdf_nbuf_map_ht, &meta->node, (size_t)nbuf);
qdf_spin_unlock_irqrestore(&qdf_nbuf_map_lock);
+
+ return QDF_STATUS_SUCCESS;
}
static void
@@ -493,7 +495,11 @@ QDF_STATUS qdf_nbuf_map_debug(qdf_device_t osdev,
const char *file,
uint32_t line)
{
- qdf_nbuf_track_map(buf, file, line);
+ QDF_STATUS status;
+
+ status = qdf_nbuf_track_map(buf, file, line);
+ if (QDF_IS_STATUS_ERROR(status))
+ return status;
return __qdf_nbuf_map(osdev, buf, dir);
}
@@ -514,7 +520,11 @@ QDF_STATUS qdf_nbuf_map_single_debug(qdf_device_t osdev,
const char *file,
uint32_t line)
{
- qdf_nbuf_track_map(buf, file, line);
+ QDF_STATUS status;
+
+ status = qdf_nbuf_track_map(buf, file, line);
+ if (QDF_IS_STATUS_ERROR(status))
+ return status;
return __qdf_nbuf_map_single(osdev, buf, dir);
}
@@ -536,7 +546,11 @@ QDF_STATUS qdf_nbuf_map_nbytes_debug(qdf_device_t osdev,
const char *file,
uint32_t line)
{
- qdf_nbuf_track_map(buf, file, line);
+ QDF_STATUS status;
+
+ status = qdf_nbuf_track_map(buf, file, line);
+ if (QDF_IS_STATUS_ERROR(status))
+ return status;
return __qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes);
}
@@ -559,7 +573,11 @@ QDF_STATUS qdf_nbuf_map_nbytes_single_debug(qdf_device_t osdev,
const char *file,
uint32_t line)
{
- qdf_nbuf_track_map(buf, file, line);
+ QDF_STATUS status;
+
+ status = qdf_nbuf_track_map(buf, file, line);
+ if (QDF_IS_STATUS_ERROR(status))
+ return status;
return __qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes);
}