mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-24 05:29:04 -04:00
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
This commit is contained in:
parent
4082a0951f
commit
5819e29cbb
1 changed files with 25 additions and 7 deletions
|
|
@ -537,7 +537,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;
|
||||
|
|
@ -545,7 +545,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);
|
||||
|
|
@ -558,7 +558,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;
|
||||
|
|
@ -568,6 +568,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
|
||||
|
|
@ -600,7 +602,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);
|
||||
}
|
||||
|
|
@ -621,7 +627,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);
|
||||
}
|
||||
|
|
@ -643,7 +653,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);
|
||||
}
|
||||
|
|
@ -666,7 +680,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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue