From 22b406cc1322f453576ae28bf2c28d33c0ccfd86 Mon Sep 17 00:00:00 2001 From: Yun Park Date: Thu, 8 Jun 2017 10:15:42 -0700 Subject: [PATCH] qcacmn: Fix NULL dereference of peer from DP_STATS macros Fix NULL dereference of peer from DP_STATS macros Change-Id: I25b6269fe8e9b1deccaa38a7499167a156db6f37 CRs-Fixed: 2058483 --- dp/wifi3.0/dp_internal.h | 12 +++++++----- dp/wifi3.0/dp_rx.c | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dp/wifi3.0/dp_internal.h b/dp/wifi3.0/dp_internal.h index c553b7a50eea..d6f241fed724 100644 --- a/dp/wifi3.0/dp_internal.h +++ b/dp/wifi3.0/dp_internal.h @@ -74,24 +74,26 @@ while (0) #ifndef DISABLE_DP_STATS #define DP_STATS_INC(_handle, _field, _delta) \ { \ - _handle->stats._field += _delta; \ + if (likely(_handle)) \ + _handle->stats._field += _delta; \ } #define DP_STATS_INCC(_handle, _field, _delta, _cond) \ { \ - if (_cond) { \ + if (_cond && likely(_handle)) \ _handle->stats._field += _delta; \ - } \ } #define DP_STATS_DEC(_handle, _field, _delta) \ { \ - _handle->stats._field -= _delta; \ + if (likely(_handle)) \ + _handle->stats._field -= _delta; \ } #define DP_STATS_UPD(_handle, _field, _delta) \ { \ - _handle->stats._field = _delta; \ + if (likely(_handle)) \ + _handle->stats._field = _delta; \ } #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) \ diff --git a/dp/wifi3.0/dp_rx.c b/dp/wifi3.0/dp_rx.c index 42b8877d61ad..862655d4df79 100644 --- a/dp/wifi3.0/dp_rx.c +++ b/dp/wifi3.0/dp_rx.c @@ -1290,7 +1290,7 @@ done: DP_STATS_INC_PKT(peer, rx.to_stack, 1, pkt_len); - if ((pdev->enhanced_stats_en) && + if ((pdev->enhanced_stats_en) && likely(peer) && hal_rx_attn_first_mpdu_get(rx_tlv_hdr)) { if (soc->cdp_soc.ol_ops->update_dp_stats) { soc->cdp_soc.ol_ops->update_dp_stats(