Replace kmalloc with kmalloc_array
cover Replace kmalloc with kmalloc_array
Replace kmalloc with specialized function kmalloc_array when the size is a multiplication of:
number_of_elements * size_of_element
Done with coccinelle:
@replace@
identifier a, b;
expression e, f;
@@
(
- a = kmalloc(e * f, b);
+ a = kmalloc_array(e, f, b);
)
Cristina Moraru (3):
staging: rtl8712: Replace kmalloc with kmalloc_array
staging: octeon-usb: Replace kmalloc with kmalloc_array
staging: rdma: Replace kmalloc with kmalloc_array
drivers/staging/octeon-usb/octeon-hcd.c | 6 +++--- drivers/staging/rdma/amso1100/c2_provider.c | 2 +- drivers/staging/rdma/ipath/ipath_verbs.c | 4 ++-- drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/3 staging: rtl8712: Replace kmalloc with kmalloc_array
Replace kmalloc with specialized function kmalloc_array when the size is a multiplication of:
number_of_elements * size_of_element
--- drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/rtl871x_mlme.c +2 -2
@@ -62,8 +62,8 @@ static sint _init_mlme_priv(struct _adapter *padapter)_init_queue (&(pmlmepriv->scanned_queue));set_scanned_network_val (pmlmepriv,0 );memset (&pmlmepriv->assoc_ssid,0 ,sizeof (struct ndis_802_11_ssid )); - pbuf =kmalloc (MAX_BSS_CNT * (sizeof (struct wlan_network )), -GFP_ATOMIC ); + pbuf =kmalloc_array (MAX_BSS_CNT ,sizeof (struct wlan_network ), +GFP_ATOMIC );if (pbuf ==NULL )return _FAIL; pmlmepriv->free_bss_buf = pbuf;
Signature · 1 line
1.9.1
PATCH 2/3 staging: octeon-usb: Replace kmalloc with kmalloc_array
In reply to Cristina MoraruReplace kmalloc with specialized function kmalloc_array when the size is a multiplication of:
number_of_elements * size_of_element
--- drivers/staging/octeon-usb/octeon-hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/octeon-usb/octeon-hcd.c +3 -3
@@ -3216,9 +3216,9 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd,* Allocate a structure to use for our private list of * isochronous packets. */ - iso_packet =kmalloc (urb->number_of_packets * -sizeof (struct cvmx_usb_iso_packet ), -GFP_ATOMIC ); + iso_packet =kmalloc_array (urb->number_of_packets, +sizeof (struct cvmx_usb_iso_packet ), +GFP_ATOMIC );if (iso_packet) {int i;/* Fill the list with the data from the URB */
Signature · 1 line
1.9.1
PATCH 3/3 staging: rdma: Replace kmalloc with kmalloc_array
In reply to Cristina MoraruReplace kmalloc with specialized function kmalloc_array when the size is a multiplication of:
number_of_elements * size_of_element
--- drivers/staging/rdma/amso1100/c2_provider.c | 2 +- drivers/staging/rdma/ipath/ipath_verbs.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rdma/amso1100/c2_provider.c +1 -1
@@ -462,7 +462,7 @@ static struct ib_mr *c2_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, shift =ffs (c2mr->umem->page_size) -1 ; n = c2mr->umem->nmap; - pages =kmalloc (n *sizeof (u64),GFP_KERNEL ); + pages =kmalloc_array (n,sizeof (u64),GFP_KERNEL );if (!pages) { err = -ENOMEM ; goto err;
drivers/staging/rdma/ipath/ipath_verbs.c +2 -2
@@ -2025,8 +2025,8 @@ int ipath_register_ib_device(struct ipath_devdata *dd) dev = &idev->ibdev;if (dd->ipath_sdma_descq_cnt) { - tx =kmalloc (dd->ipath_sdma_descq_cnt *sizeof *tx, -GFP_KERNEL ); + tx =kmalloc_array (dd->ipath_sdma_descq_cnt,sizeof *tx, +GFP_KERNEL );if (tx ==NULL ) { ret = -ENOMEM ; goto err_tx;
Signature · 1 line
1.9.1
Quoted 21 lines · Cristina Moraru
Replace kmalloc with specialized function
kmalloc_arraywhen the size is a multiplication of:
number_of_elements*size_of_elementDone with coccinelle:
@replace@
identifier a, b;
expression e, f;
@@
(
- a =kmalloc(e * f, b);
+ a =kmalloc_array(e, f, b);
)Cristina Moraru (3):
staging: rtl8712: Replace kmalloc withkmalloc_array
staging: octeon-usb: Replace kmalloc withkmalloc_array
staging: rdma: Replace kmalloc withkmalloc_array
Quoted 5 lines
drivers/staging/octeon-usb/octeon-hcd.c | 6 +++--- drivers/staging/rdma/amso1100/c2_provider.c | 2 +- drivers/staging/rdma/ipath/ipath_verbs.c | 4 ++-- drivers/staging/rtl8712/rtl871x_mlme.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
For all patches in this series: