From: Dan Carpenter <error27@gmail.com>
To: quic_kvalo@quicinc.com
Cc: ath12k@lists.infradead.org
Subject: [bug report] wifi: ath12k: confusing alignment
Date: Thu, 16 Feb 2023 17:01:04 +0300 [thread overview]
Message-ID: <Y+43IBa2D6Q0EA41@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:94 ath12k_dbring_fill_bufs() warn: assigning negative subtract to bytes: 'size = 8 + ring->buf_sz + align - 1'
drivers/net/wireless/ath/ath12k/dbring.c:288 ath12k_dbring_buffer_release_event() warn: assigning negative subtract to bytes: 'size = 8 + ring->buf_sz + ring->buf_align - 1'
drivers/net/wireless/ath/ath12k/dbring.c
75 static int ath12k_dbring_fill_bufs(struct ath12k *ar,
76 struct ath12k_dbring *ring,
77 gfp_t gfp)
78 {
79 struct ath12k_dbring_element *buff;
80 struct hal_srng *srng;
81 struct ath12k_base *ab = ar->ab;
82 int num_remain, req_entries, num_free;
83 u32 align;
84 int size, ret;
85
86 srng = &ab->hal.srng_list[ring->refill_srng.ring_id];
87
88 spin_lock_bh(&srng->lock);
89
90 num_free = ath12k_hal_srng_src_num_free(ab, srng, true);
91 req_entries = min(num_free, ring->bufs_max);
92 num_remain = req_entries;
93 align = ring->buf_align;
--> 94 size = sizeof(*buff) + ring->buf_sz + align - 1;
Where does this - 1 come from? I feel like this should be:
size = sizeof(*buff) + ALIGN(ring->buf_sz, ring->buf_align);
95
96 while (num_remain > 0) {
97 buff = kzalloc(size, gfp);
98 if (!buff)
99 break;
100
101 ret = ath12k_dbring_bufs_replenish(ar, ring, buff, gfp);
102 if (ret) {
103 ath12k_warn(ab, "failed to replenish db ring num_remain %d req_ent %d\n",
104 num_remain, req_entries);
105 kfree(buff);
106 break;
107 }
108 num_remain--;
109 }
110
111 spin_unlock_bh(&srng->lock);
112
113 return num_remain;
114 }
regards,
dan carpenter
--
ath12k mailing list
ath12k@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/ath12k
reply other threads:[~2023-02-16 14:01 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+43IBa2D6Q0EA41@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.