This commit refactors the iwctl_giwaplist() function so that the sparse warning "the frame size of 1292 bytes is larger than 1024 bytes [-Wframe-larger-than=]" is no more. The root cause of this warning were two arrays allocated on the stack and this commit changes this - these arrays are now kmalloc'ed. As a result the function is refactored and hopefully stil working the same. I were not able to test these changes so at least the carefull review is more than welcomed. Note that my changes has broadened the set of error codes that this function can return. The new error code is ENOMEM. Luckily, this is no issue. Signed-off-by: Konrad Zapalowicz <bergo.torino@xxxxxxxxx> --- v2: - fix after the review: - remove unnecessary comments - remove unnecessary assignment - fix pointer arithmetic drivers/staging/vt6655/iwctl.c | 72 ++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index eb03e68..ae2b87f 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -714,42 +714,66 @@ int iwctl_giwaplist(struct net_device *dev, char *extra) { int ii, jj, rc = 0; - struct sockaddr sock[IW_MAX_AP]; - struct iw_quality qual[IW_MAX_AP]; + struct sockaddr *sock = NULL; + struct sockaddr *s = NULL; + struct iw_quality *qual = NULL; + struct iw_quality *q = NULL; + PKnownBSS pBSS = NULL; + PSDevice pDevice = (PSDevice)netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n"); - // Only super-user can see AP list + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST\n"); if (!capable(CAP_NET_ADMIN)) { rc = -EPERM; - return rc; + goto exit; } - if (wrq->pointer) { - PKnownBSS pBSS = &(pMgmt->sBSSList[0]); + if (!wrq->pointer) + goto exit; - for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) - continue; - if (jj >= IW_MAX_AP) - break; - memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6); - sock[jj].sa_family = ARPHRD_ETHER; - qual[jj].level = pBSS->uRSSI; - qual[jj].qual = qual[jj].noise = 0; - qual[jj].updated = 2; - jj++; - } + sock = kmalloc_array(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL); + if (!sock) { + rc = -ENOMEM; + goto exit; + } + + qual = kmalloc_array(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL); + if (!qual) { + rc = -ENOMEM; + goto exit; + } + + for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) { + pBSS = &(pMgmt->sBSSList[ii]); + + if (!pBSS->bActive) + continue; + if (jj >= IW_MAX_AP) + break; + + s = &sock[jj]; + q = &qual[jj]; - wrq->flags = 1; // Should be define'd - wrq->length = jj; - memcpy(extra, sock, sizeof(struct sockaddr)*jj); - memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj); + memcpy(s->sa_data, pBSS->abyBSSID, 6); + s->sa_family = ARPHRD_ETHER; + q->level = pBSS->uRSSI; + q->qual = 0; + q->noise = 0; + q->updated = 2; + jj++; } + wrq->flags = 1; /* Should be define'd */ + wrq->length = jj; + memcpy(extra, sock, sizeof(struct sockaddr) * jj); + memcpy(extra + sizeof(struct sockaddr) * jj, + qual, + sizeof(struct iw_quality) * jj); +exit: + kfree(sock); + kfree(qual); return rc; } -- 1.8.1.2 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel