public inbox for ath12k@lists.infradead.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: quic_kvalo@quicinc.com
Cc: ath12k@lists.infradead.org
Subject: [bug report] wifi: ath12k: sleeping in atomic bugs
Date: Thu, 16 Feb 2023 16:59:00 +0300	[thread overview]
Message-ID: <Y+42pE/OAPfgvWCe@kili> (raw)

Hello Kalle Valo,

The patch d889913205cf: "wifi: ath12k: driver for Qualcomm Wi-Fi 7
devices" from Nov 28, 2022, leads to the following Smatch static
checker warning:

drivers/net/wireless/ath/ath12k/dbring.c:39 ath12k_dbring_bufs_replenish() warn: make sure GFP_ATOMIC set here
drivers/net/wireless/ath/ath12k/dbring.c:97 ath12k_dbring_fill_bufs() warn: sleeping in atomic context

drivers/net/wireless/ath/ath12k/dbring.c
    10 static int ath12k_dbring_bufs_replenish(struct ath12k *ar,
    11                                         struct ath12k_dbring *ring,
    12                                         struct ath12k_dbring_element *buff,
    13                                         gfp_t gfp)
    14 {
    15         struct ath12k_base *ab = ar->ab;
    16         struct hal_srng *srng;
    17         dma_addr_t paddr;
    18         void *ptr_aligned, *ptr_unaligned, *desc;
    19         int ret;
    20         int buf_id;
    21         u32 cookie;
    22 
    23         srng = &ab->hal.srng_list[ring->refill_srng.ring_id];
    24 
    25         lockdep_assert_held(&srng->lock);
    26 
    27         ath12k_hal_srng_access_begin(ab, srng);
    28 
    29         ptr_unaligned = buff->payload;
    30         ptr_aligned = PTR_ALIGN(ptr_unaligned, ring->buf_align);
    31         paddr = dma_map_single(ab->dev, ptr_aligned, ring->buf_sz,
    32                                DMA_FROM_DEVICE);
    33 
    34         ret = dma_mapping_error(ab->dev, paddr);
    35         if (ret)
    36                 goto err;
    37 
    38         spin_lock_bh(&ring->idr_lock);
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Atomic context.

--> 39         buf_id = idr_alloc(&ring->bufs_idr, buff, 0, ring->bufs_max, gfp);
    40         spin_unlock_bh(&ring->idr_lock);

ath12k_dbring_buf_setup() passes GFP_KERNEL to here as the gfp.  I think
this is a sleeping in atomic bug.  The caller definitely has a bug.

    41         if (buf_id < 0) {
    42                 ret = -ENOBUFS;
    43                 goto err_dma_unmap;
    44         }
    45 

regards,
dan carpenter

-- 
ath12k mailing list
ath12k@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/ath12k

                 reply	other threads:[~2023-02-16 13:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y+42pE/OAPfgvWCe@kili \
    --to=error27@gmail.com \
    --cc=ath12k@lists.infradead.org \
    --cc=quic_kvalo@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox