Skip to content

Commit 3d6b77a

Browse files
committed
Merge tag 'staging-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver fixes from Greg KH: "Here are three small staging driver fixes for 6.5-rc4 that resolve some reported problems. These fixes are: - fix for an old bug in the r8712 driver - fbtft driver fix for a spi device - potential overflow fix in the ks7010 driver All of these have been in linux-next with no reported problems" * tag 'staging-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: staging: ks7010: potential buffer overflow in ks_wlan_set_encode_ext() staging: fbtft: ili9341: use macro FBTFT_REGISTER_SPI_DRIVER staging: r8712: Fix memory leak in _r8712_init_xmit_priv()
2 parents cf270e7 + 5f1c703 commit 3d6b77a

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

drivers/staging/fbtft/fb_ili9341.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static struct fbtft_display display = {
145145
},
146146
};
147147

148-
FBTFT_REGISTER_DRIVER(DRVNAME, "ilitek,ili9341", &display);
148+
FBTFT_REGISTER_SPI_DRIVER(DRVNAME, "ilitek", "ili9341", &display);
149149

150150
MODULE_ALIAS("spi:" DRVNAME);
151151
MODULE_ALIAS("platform:" DRVNAME);

drivers/staging/ks7010/ks_wlan_net.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,8 +1583,10 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
15831583
commit |= SME_WEP_FLAG;
15841584
}
15851585
if (enc->key_len) {
1586-
memcpy(&key->key_val[0], &enc->key[0], enc->key_len);
1587-
key->key_len = enc->key_len;
1586+
int key_len = clamp_val(enc->key_len, 0, IW_ENCODING_TOKEN_MAX);
1587+
1588+
memcpy(&key->key_val[0], &enc->key[0], key_len);
1589+
key->key_len = key_len;
15881590
commit |= (SME_WEP_VAL1 << index);
15891591
}
15901592
break;

drivers/staging/rtl8712/rtl871x_xmit.c

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "osdep_intf.h"
2222
#include "usb_ops.h"
2323

24+
#include <linux/usb.h>
2425
#include <linux/ieee80211.h>
2526

2627
static const u8 P802_1H_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0xf8};
@@ -55,6 +56,7 @@ int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
5556
sint i;
5657
struct xmit_buf *pxmitbuf;
5758
struct xmit_frame *pxframe;
59+
int j;
5860

5961
memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv));
6062
spin_lock_init(&pxmitpriv->lock);
@@ -117,25 +119,26 @@ int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
117119
_init_queue(&pxmitpriv->pending_xmitbuf_queue);
118120
pxmitpriv->pallocated_xmitbuf =
119121
kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4, GFP_ATOMIC);
120-
if (!pxmitpriv->pallocated_xmitbuf) {
121-
kfree(pxmitpriv->pallocated_frame_buf);
122-
pxmitpriv->pallocated_frame_buf = NULL;
123-
return -ENOMEM;
124-
}
122+
if (!pxmitpriv->pallocated_xmitbuf)
123+
goto clean_up_frame_buf;
125124
pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 -
126125
((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3);
127126
pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
128127
for (i = 0; i < NR_XMITBUFF; i++) {
129128
INIT_LIST_HEAD(&pxmitbuf->list);
130129
pxmitbuf->pallocated_buf =
131130
kmalloc(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ, GFP_ATOMIC);
132-
if (!pxmitbuf->pallocated_buf)
133-
return -ENOMEM;
131+
if (!pxmitbuf->pallocated_buf) {
132+
j = 0;
133+
goto clean_up_alloc_buf;
134+
}
134135
pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ -
135136
((addr_t) (pxmitbuf->pallocated_buf) &
136137
(XMITBUF_ALIGN_SZ - 1));
137-
if (r8712_xmit_resource_alloc(padapter, pxmitbuf))
138-
return -ENOMEM;
138+
if (r8712_xmit_resource_alloc(padapter, pxmitbuf)) {
139+
j = 1;
140+
goto clean_up_alloc_buf;
141+
}
139142
list_add_tail(&pxmitbuf->list,
140143
&(pxmitpriv->free_xmitbuf_queue.queue));
141144
pxmitbuf++;
@@ -146,6 +149,28 @@ int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
146149
init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
147150
tasklet_setup(&pxmitpriv->xmit_tasklet, r8712_xmit_bh);
148151
return 0;
152+
153+
clean_up_alloc_buf:
154+
if (j) {
155+
/* failure happened in r8712_xmit_resource_alloc()
156+
* delete extra pxmitbuf->pallocated_buf
157+
*/
158+
kfree(pxmitbuf->pallocated_buf);
159+
}
160+
for (j = 0; j < i; j++) {
161+
int k;
162+
163+
pxmitbuf--; /* reset pointer */
164+
kfree(pxmitbuf->pallocated_buf);
165+
for (k = 0; k < 8; k++) /* delete xmit urb's */
166+
usb_free_urb(pxmitbuf->pxmit_urb[k]);
167+
}
168+
kfree(pxmitpriv->pallocated_xmitbuf);
169+
pxmitpriv->pallocated_xmitbuf = NULL;
170+
clean_up_frame_buf:
171+
kfree(pxmitpriv->pallocated_frame_buf);
172+
pxmitpriv->pallocated_frame_buf = NULL;
173+
return -ENOMEM;
149174
}
150175

151176
void _free_xmit_priv(struct xmit_priv *pxmitpriv)

drivers/staging/rtl8712/xmit_linux.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ int r8712_xmit_resource_alloc(struct _adapter *padapter,
112112
for (i = 0; i < 8; i++) {
113113
pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
114114
if (!pxmitbuf->pxmit_urb[i]) {
115+
int k;
116+
117+
for (k = i - 1; k >= 0; k--) {
118+
/* handle allocation errors part way through loop */
119+
usb_free_urb(pxmitbuf->pxmit_urb[k]);
120+
}
115121
netdev_err(padapter->pnetdev, "pxmitbuf->pxmit_urb[i] == NULL\n");
116122
return -ENOMEM;
117123
}

0 commit comments

Comments
 (0)