Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1548739
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] staging: r8192U_core: Use kmalloc_array() in rtl8192_usb_initendpoints() |
| Date | 2016-12-30 22:00 +0100 |
| Message-ID | <sUcrn-Qi-3@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 30 Dec 2016 21:43:22 +0100
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data type by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/rtl8192u/r8192U_core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index fdb03dccb449..e0791d357259 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1682,8 +1682,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
{
struct r8192_priv *priv = ieee80211_priv(dev);
- priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1),
- GFP_KERNEL);
+ priv->rx_urb = kmalloc_array(MAX_RX_URB + 1,
+ sizeof(*priv->rx_urb),
+ GFP_KERNEL);
if (!priv->rx_urb)
return -ENOMEM;
--
2.11.0
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH] staging: r8192U_core: Use kmalloc_array() in rtl8192_usb_initendpoints() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-12-30 22:00 +0100
csiph-web