diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /net/bluetooth | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
avoid scalar types (which need careful case-by-case checking), and
instead replace kmalloc-family calls that allocate struct or union
object instances:
Single allocations: kmalloc(sizeof(TYPE), ...)
are replaced with: kmalloc_obj(TYPE, ...)
Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...)
are replaced with: kmalloc_objs(TYPE, COUNT, ...)
Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...)
are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...)
(where TYPE may also be *VAR)
The resulting allocations no longer return "void *", instead returning
"TYPE *".
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'net/bluetooth')
| -rw-r--r-- | net/bluetooth/6lowpan.c | 6 | ||||
| -rw-r--r-- | net/bluetooth/cmtp/capi.c | 2 | ||||
| -rw-r--r-- | net/bluetooth/cmtp/core.c | 2 | ||||
| -rw-r--r-- | net/bluetooth/hci_conn.c | 12 | ||||
| -rw-r--r-- | net/bluetooth/hci_core.c | 22 | ||||
| -rw-r--r-- | net/bluetooth/hci_sync.c | 10 | ||||
| -rw-r--r-- | net/bluetooth/hidp/core.c | 2 | ||||
| -rw-r--r-- | net/bluetooth/iso.c | 2 | ||||
| -rw-r--r-- | net/bluetooth/l2cap_core.c | 4 | ||||
| -rw-r--r-- | net/bluetooth/l2cap_sock.c | 4 | ||||
| -rw-r--r-- | net/bluetooth/mgmt.c | 14 | ||||
| -rw-r--r-- | net/bluetooth/mgmt_util.c | 4 | ||||
| -rw-r--r-- | net/bluetooth/msft.c | 8 | ||||
| -rw-r--r-- | net/bluetooth/rfcomm/core.c | 4 | ||||
| -rw-r--r-- | net/bluetooth/rfcomm/tty.c | 4 | ||||
| -rw-r--r-- | net/bluetooth/sco.c | 2 | ||||
| -rw-r--r-- | net/bluetooth/smp.c | 8 |
17 files changed, 55 insertions, 55 deletions
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 2c21ae8abadc..acaf7c9e4a69 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -645,7 +645,7 @@ static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan, { struct lowpan_peer *peer; - peer = kzalloc(sizeof(*peer), GFP_ATOMIC); + peer = kzalloc_obj(*peer, GFP_ATOMIC); if (!peer) return NULL; @@ -1107,7 +1107,7 @@ static int lowpan_enable_set(void *data, u64 val) { struct set_enable *set_enable; - set_enable = kzalloc(sizeof(*set_enable), GFP_KERNEL); + set_enable = kzalloc_obj(*set_enable, GFP_KERNEL); if (!set_enable) return -ENOMEM; @@ -1245,7 +1245,7 @@ static void disconnect_devices(void) rcu_read_lock(); list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) { - new_dev = kmalloc(sizeof(*new_dev), GFP_ATOMIC); + new_dev = kmalloc_obj(*new_dev, GFP_ATOMIC); if (!new_dev) break; diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c index 884703fda979..df4edd43176e 100644 --- a/net/bluetooth/cmtp/capi.c +++ b/net/bluetooth/cmtp/capi.c @@ -72,7 +72,7 @@ static struct cmtp_application *cmtp_application_add(struct cmtp_session *session, __u16 appl) { - struct cmtp_application *app = kzalloc(sizeof(*app), GFP_KERNEL); + struct cmtp_application *app = kzalloc_obj(*app, GFP_KERNEL); BT_DBG("session %p application %p appl %u", session, app, appl); diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c index 90d130588a3e..ebfa049598dc 100644 --- a/net/bluetooth/cmtp/core.c +++ b/net/bluetooth/cmtp/core.c @@ -341,7 +341,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock) if (req->flags & ~valid_flags) return -EINVAL; - session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL); + session = kzalloc_obj(struct cmtp_session, GFP_KERNEL); if (!session) return -ENOMEM; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 0795818963a5..02d33fe11042 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -462,7 +462,7 @@ bool hci_setup_sync(struct hci_conn *conn, __u16 handle) struct conn_handle_t *conn_handle; if (enhanced_sync_conn_capable(conn->hdev)) { - conn_handle = kzalloc(sizeof(*conn_handle), GFP_KERNEL); + conn_handle = kzalloc_obj(*conn_handle, GFP_KERNEL); if (!conn_handle) return false; @@ -726,7 +726,7 @@ static int hci_le_terminate_big(struct hci_dev *hdev, struct hci_conn *conn) bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", conn->iso_qos.bcast.big, conn->iso_qos.bcast.bis); - d = kzalloc(sizeof(*d), GFP_KERNEL); + d = kzalloc_obj(*d, GFP_KERNEL); if (!d) return -ENOMEM; @@ -777,7 +777,7 @@ static int hci_le_big_terminate(struct hci_dev *hdev, struct hci_conn *conn) bt_dev_dbg(hdev, "hcon %p big 0x%2.2x sync_handle 0x%4.4x", conn, conn->iso_qos.bcast.big, conn->sync_handle); - d = kzalloc(sizeof(*d), GFP_KERNEL); + d = kzalloc_obj(*d, GFP_KERNEL); if (!d) return -ENOMEM; @@ -960,7 +960,7 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type, bt_dev_dbg(hdev, "dst %pMR handle 0x%4.4x", dst, handle); - conn = kzalloc(sizeof(*conn), GFP_KERNEL); + conn = kzalloc_obj(*conn, GFP_KERNEL); if (!conn) return ERR_PTR(-ENOMEM); @@ -1739,7 +1739,7 @@ static struct hci_link *hci_conn_link(struct hci_conn *parent, if (conn->parent) return NULL; - link = kzalloc(sizeof(*link), GFP_KERNEL); + link = kzalloc_obj(*link, GFP_KERNEL); if (!link) return NULL; @@ -2781,7 +2781,7 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn) return NULL; } - chan = kzalloc(sizeof(*chan), GFP_KERNEL); + chan = kzalloc_obj(*chan, GFP_KERNEL); if (!chan) return NULL; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index b069607b145b..a0cad792be0b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -262,7 +262,7 @@ u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, } /* Entry not in the cache. Add new one. */ - ie = kzalloc(sizeof(*ie), GFP_KERNEL); + ie = kzalloc_obj(*ie, GFP_KERNEL); if (!ie) { flags |= MGMT_DEV_FOUND_CONFIRM_NAME; goto done; @@ -797,7 +797,7 @@ int hci_get_dev_list(void __user *arg) if (!dev_num || dev_num > (PAGE_SIZE * 2) / sizeof(*dr)) return -EINVAL; - dl = kzalloc(struct_size(dl, dev_req, dev_num), GFP_KERNEL); + dl = kzalloc_flex(*dl, dev_req, dev_num, GFP_KERNEL); if (!dl) return -ENOMEM; @@ -1286,7 +1286,7 @@ struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, key = old_key; } else { old_key_type = conn ? conn->key_type : 0xff; - key = kzalloc(sizeof(*key), GFP_KERNEL); + key = kzalloc_obj(*key, GFP_KERNEL); if (!key) return NULL; list_add_rcu(&key->list, &hdev->link_keys); @@ -1331,7 +1331,7 @@ struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, if (old_key) key = old_key; else { - key = kzalloc(sizeof(*key), GFP_KERNEL); + key = kzalloc_obj(*key, GFP_KERNEL); if (!key) return NULL; list_add_rcu(&key->list, &hdev->long_term_keys); @@ -1356,7 +1356,7 @@ struct smp_irk *hci_add_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, irk = hci_find_irk_by_addr(hdev, bdaddr, addr_type); if (!irk) { - irk = kzalloc(sizeof(*irk), GFP_KERNEL); + irk = kzalloc_obj(*irk, GFP_KERNEL); if (!irk) return NULL; @@ -1550,7 +1550,7 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, data = hci_find_remote_oob_data(hdev, bdaddr, bdaddr_type); if (!data) { - data = kmalloc(sizeof(*data), GFP_KERNEL); + data = kmalloc_obj(*data, GFP_KERNEL); if (!data) return -ENOMEM; @@ -1718,7 +1718,7 @@ struct adv_info *hci_add_adv_instance(struct hci_dev *hdev, u8 instance, instance < 1 || instance > hdev->le_num_of_adv_sets + 1) return ERR_PTR(-EOVERFLOW); - adv = kzalloc(sizeof(*adv), GFP_KERNEL); + adv = kzalloc_obj(*adv, GFP_KERNEL); if (!adv) return ERR_PTR(-ENOMEM); @@ -2107,7 +2107,7 @@ int hci_bdaddr_list_add(struct list_head *list, bdaddr_t *bdaddr, u8 type) if (hci_bdaddr_list_lookup(list, bdaddr, type)) return -EEXIST; - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kzalloc_obj(*entry, GFP_KERNEL); if (!entry) return -ENOMEM; @@ -2130,7 +2130,7 @@ int hci_bdaddr_list_add_with_irk(struct list_head *list, bdaddr_t *bdaddr, if (hci_bdaddr_list_lookup(list, bdaddr, type)) return -EEXIST; - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kzalloc_obj(*entry, GFP_KERNEL); if (!entry) return -ENOMEM; @@ -2159,7 +2159,7 @@ int hci_bdaddr_list_add_with_flags(struct list_head *list, bdaddr_t *bdaddr, if (hci_bdaddr_list_lookup(list, bdaddr, type)) return -EEXIST; - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kzalloc_obj(*entry, GFP_KERNEL); if (!entry) return -ENOMEM; @@ -2276,7 +2276,7 @@ struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev, if (params) return params; - params = kzalloc(sizeof(*params), GFP_KERNEL); + params = kzalloc_obj(*params, GFP_KERNEL); if (!params) { bt_dev_err(hdev, "out of memory"); return NULL; diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index f04a90bce4a9..ed5db3eb3df3 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -711,7 +711,7 @@ int hci_cmd_sync_submit(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, goto unlock; } - entry = kmalloc(sizeof(*entry), GFP_KERNEL); + entry = kmalloc_obj(*entry, GFP_KERNEL); if (!entry) { err = -ENOMEM; goto unlock; @@ -2685,7 +2685,7 @@ static struct conn_params *conn_params_copy(struct list_head *list, size_t *n) rcu_read_unlock(); - p = kvcalloc(*n, sizeof(struct conn_params), GFP_KERNEL); + p = kvzalloc_objs(struct conn_params, *n, GFP_KERNEL); if (!p) return NULL; @@ -7341,7 +7341,7 @@ int hci_past_sync(struct hci_conn *conn, struct hci_conn *le) if (!past_sender_capable(conn->hdev)) return -EOPNOTSUPP; - data = kmalloc(sizeof(*data), GFP_KERNEL); + data = kmalloc_obj(*data, GFP_KERNEL); if (!data) return -ENOMEM; @@ -7473,7 +7473,7 @@ int hci_acl_change_pkt_type(struct hci_conn *conn, u16 pkt_type) struct hci_dev *hdev = conn->hdev; struct hci_cp_change_conn_ptype *cp; - cp = kmalloc(sizeof(*cp), GFP_KERNEL); + cp = kmalloc_obj(*cp, GFP_KERNEL); if (!cp) return -ENOMEM; @@ -7508,7 +7508,7 @@ int hci_le_set_phy(struct hci_conn *conn, u8 tx_phys, u8 rx_phys) struct hci_dev *hdev = conn->hdev; struct hci_cp_le_set_phy *cp; - cp = kmalloc(sizeof(*cp), GFP_KERNEL); + cp = kmalloc_obj(*cp, GFP_KERNEL); if (!cp) return -ENOMEM; diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 6724adce615b..a91d5452f24a 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -920,7 +920,7 @@ static int hidp_session_new(struct hidp_session **out, const bdaddr_t *bdaddr, ctrl = bt_sk(ctrl_sock->sk); intr = bt_sk(intr_sock->sk); - session = kzalloc(sizeof(*session), GFP_KERNEL); + session = kzalloc_obj(*session, GFP_KERNEL); if (!session) return -ENOMEM; diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 1459ab161fd2..693271af6c22 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -212,7 +212,7 @@ static struct iso_conn *iso_conn_add(struct hci_conn *hcon) return conn; } - conn = kzalloc(sizeof(*conn), GFP_KERNEL); + conn = kzalloc_obj(*conn, GFP_KERNEL); if (!conn) return NULL; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index b628b0fa39b2..4804377781b6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -442,7 +442,7 @@ struct l2cap_chan *l2cap_chan_create(void) { struct l2cap_chan *chan; - chan = kzalloc(sizeof(*chan), GFP_ATOMIC); + chan = kzalloc_obj(*chan, GFP_ATOMIC); if (!chan) return NULL; @@ -6902,7 +6902,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) if (!hchan) return NULL; - conn = kzalloc(sizeof(*conn), GFP_KERNEL); + conn = kzalloc_obj(*conn, GFP_KERNEL); if (!conn) { hci_chan_del(hchan); return NULL; diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 3ba3ce7eaa98..66ab920d8f50 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1564,8 +1564,8 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) (chan->mode == L2CAP_MODE_ERTM || chan->mode == L2CAP_MODE_LE_FLOWCTL || chan->mode == L2CAP_MODE_EXT_FLOWCTL)) { - struct l2cap_rx_busy *rx_busy = - kmalloc(sizeof(*rx_busy), GFP_KERNEL); + struct l2cap_rx_busy *rx_busy = kmalloc_obj(*rx_busy, + GFP_KERNEL); if (!rx_busy) { err = -ENOMEM; goto done; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0e46f9e08b10..c9725ca3356c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -560,7 +560,7 @@ static int read_ext_index_list(struct sock *sk, struct hci_dev *hdev, list_for_each_entry(d, &hci_dev_list, list) count++; - rp = kmalloc(struct_size(rp, entry, count), GFP_ATOMIC); + rp = kmalloc_flex(*rp, entry, count, GFP_ATOMIC); if (!rp) { read_unlock(&hci_dev_list_lock); return -ENOMEM; @@ -2767,7 +2767,7 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) goto failed; } - uuid = kmalloc(sizeof(*uuid), GFP_KERNEL); + uuid = kmalloc_obj(*uuid, GFP_KERNEL); if (!uuid) { err = -ENOMEM; goto failed; @@ -3360,7 +3360,7 @@ static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data, i++; } - rp = kmalloc(struct_size(rp, addr, i), GFP_KERNEL); + rp = kmalloc_flex(*rp, addr, i, GFP_KERNEL); if (!rp) { err = -ENOMEM; goto unlock; @@ -4377,7 +4377,7 @@ static int set_blocked_keys(struct sock *sk, struct hci_dev *hdev, void *data, hci_blocked_keys_clear(hdev); for (i = 0; i < key_count; ++i) { - struct blocked_key *b = kzalloc(sizeof(*b), GFP_KERNEL); + struct blocked_key *b = kzalloc_obj(*b, GFP_KERNEL); if (!b) { err = MGMT_STATUS_NO_RESOURCES; @@ -5490,7 +5490,7 @@ static u8 parse_adv_monitor_pattern(struct adv_monitor *m, u8 pattern_count, (offset + length) > HCI_MAX_AD_LENGTH) return MGMT_STATUS_INVALID_PARAMS; - p = kmalloc(sizeof(*p), GFP_KERNEL); + p = kmalloc_obj(*p, GFP_KERNEL); if (!p) return MGMT_STATUS_NO_RESOURCES; @@ -5527,7 +5527,7 @@ static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev, goto done; } - m = kzalloc(sizeof(*m), GFP_KERNEL); + m = kzalloc_obj(*m, GFP_KERNEL); if (!m) { status = MGMT_STATUS_NO_RESOURCES; goto done; @@ -5564,7 +5564,7 @@ static int add_adv_patterns_monitor_rssi(struct sock *sk, struct hci_dev *hdev, goto done; } - m = kzalloc(sizeof(*m), GFP_KERNEL); + m = kzalloc_obj(*m, GFP_KERNEL); if (!m) { status = MGMT_STATUS_NO_RESOURCES; goto done; diff --git a/net/bluetooth/mgmt_util.c b/net/bluetooth/mgmt_util.c index aa7b5585cb26..4ed16ca8771d 100644 --- a/net/bluetooth/mgmt_util.c +++ b/net/bluetooth/mgmt_util.c @@ -266,7 +266,7 @@ struct mgmt_pending_cmd *mgmt_pending_new(struct sock *sk, u16 opcode, { struct mgmt_pending_cmd *cmd; - cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); + cmd = kzalloc_obj(*cmd, GFP_KERNEL); if (!cmd) return NULL; @@ -413,7 +413,7 @@ struct mgmt_mesh_tx *mgmt_mesh_add(struct sock *sk, struct hci_dev *hdev, { struct mgmt_mesh_tx *mesh_tx; - mesh_tx = kzalloc(sizeof(*mesh_tx), GFP_KERNEL); + mesh_tx = kzalloc_obj(*mesh_tx, GFP_KERNEL); if (!mesh_tx) return NULL; diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c index c560d8467669..25cde1ea5d23 100644 --- a/net/bluetooth/msft.c +++ b/net/bluetooth/msft.c @@ -276,7 +276,7 @@ static int msft_le_monitor_advertisement_cb(struct hci_dev *hdev, u16 opcode, if (status) goto unlock; - handle_data = kmalloc(sizeof(*handle_data), GFP_KERNEL); + handle_data = kmalloc_obj(*handle_data, GFP_KERNEL); if (!handle_data) { status = HCI_ERROR_UNSPECIFIED; goto unlock; @@ -756,7 +756,7 @@ void msft_register(struct hci_dev *hdev) bt_dev_dbg(hdev, "Register MSFT extension"); - msft = kzalloc(sizeof(*msft), GFP_KERNEL); + msft = kzalloc_obj(*msft, GFP_KERNEL); if (!msft) { bt_dev_err(hdev, "Failed to register MSFT extension"); return; @@ -790,7 +790,7 @@ static void msft_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, { struct monitored_device *dev; - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kmalloc_obj(*dev, GFP_KERNEL); if (!dev) { bt_dev_err(hdev, "MSFT vendor event %u: no memory", MSFT_EV_LE_MONITOR_DEVICE); @@ -932,7 +932,7 @@ static struct msft_monitor_addr_filter_data *msft_add_address_filter struct msft_data *msft = hdev->msft_data; int err; - address_filter = kzalloc(sizeof(*address_filter), GFP_KERNEL); + address_filter = kzalloc_obj(*address_filter, GFP_KERNEL); if (!address_filter) return NULL; diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 57b1dca8141f..d7718844c520 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c @@ -302,7 +302,7 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d) struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio) { - struct rfcomm_dlc *d = kzalloc(sizeof(*d), prio); + struct rfcomm_dlc *d = kzalloc_obj(*d, prio); if (!d) return NULL; @@ -680,7 +680,7 @@ int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig) /* ---- RFCOMM sessions ---- */ static struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state) { - struct rfcomm_session *s = kzalloc(sizeof(*s), GFP_KERNEL); + struct rfcomm_session *s = kzalloc_obj(*s, GFP_KERNEL); if (!s) return NULL; diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index b783526ab588..4d8ab1a49e92 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -221,7 +221,7 @@ static struct rfcomm_dev *__rfcomm_dev_add(struct rfcomm_dev_req *req, struct list_head *head = &rfcomm_dev_list; int err = 0; - dev = kzalloc(sizeof(struct rfcomm_dev), GFP_KERNEL); + dev = kzalloc_obj(struct rfcomm_dev, GFP_KERNEL); if (!dev) return ERR_PTR(-ENOMEM); @@ -510,7 +510,7 @@ static int rfcomm_get_dev_list(void __user *arg) if (!dev_num || dev_num > (PAGE_SIZE * 4) / sizeof(*di)) return -EINVAL; - dl = kzalloc(struct_size(dl, dev_info, dev_num), GFP_KERNEL); + dl = kzalloc_flex(*dl, dev_info, dev_num, GFP_KERNEL); if (!dl) return -ENOMEM; diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 87ba90336e80..26c5c5fe7c5a 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -204,7 +204,7 @@ static struct sco_conn *sco_conn_add(struct hci_conn *hcon) return conn; } - conn = kzalloc(sizeof(struct sco_conn), GFP_KERNEL); + conn = kzalloc_obj(struct sco_conn, GFP_KERNEL); if (!conn) return NULL; diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index bf61e8841535..e0e66dc95007 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -1344,7 +1344,7 @@ static void smp_distribute_keys(struct smp_chan *smp) /* Generate a new random key */ get_random_bytes(sign.csrk, sizeof(sign.csrk)); - csrk = kzalloc(sizeof(*csrk), GFP_KERNEL); + csrk = kzalloc_obj(*csrk, GFP_KERNEL); if (csrk) { if (hcon->sec_level > BT_SECURITY_MEDIUM) csrk->type = MGMT_CSRK_LOCAL_AUTHENTICATED; @@ -1388,7 +1388,7 @@ static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) struct l2cap_chan *chan = conn->smp; struct smp_chan *smp; - smp = kzalloc(sizeof(*smp), GFP_ATOMIC); + smp = kzalloc_obj(*smp, GFP_ATOMIC); if (!smp) return NULL; @@ -2664,7 +2664,7 @@ static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb) skb_pull(skb, sizeof(*rp)); - csrk = kzalloc(sizeof(*csrk), GFP_KERNEL); + csrk = kzalloc_obj(*csrk, GFP_KERNEL); if (csrk) { if (conn->hcon->sec_level > BT_SECURITY_MEDIUM) csrk->type = MGMT_CSRK_REMOTE_AUTHENTICATED; @@ -3293,7 +3293,7 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid) goto create_chan; } - smp = kzalloc(sizeof(*smp), GFP_KERNEL); + smp = kzalloc_obj(*smp, GFP_KERNEL); if (!smp) return ERR_PTR(-ENOMEM); |
