Skip to content

Commit

Permalink
staging: wilc1000: check for kmalloc allocation failures
Browse files Browse the repository at this point in the history
There are three kmalloc allocations that are not null checked which
potentially could lead to null pointer dereference issues. Fix this
by adding null pointer return checks.

Detected by CoverityScan, CID#1466025-27 ("Dereference null return")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Colin Ian King authored and Greg Kroah-Hartman committed Mar 22, 2018
1 parent a0e8045 commit aaea216
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/staging/wilc1000/host_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,21 @@ static s32 handle_connect(struct wilc_vif *vif,

if (conn_attr->bssid) {
hif_drv->usr_conn_req.bssid = kmalloc(6, GFP_KERNEL);
if (!hif_drv->usr_conn_req.bssid) {
result = -ENOMEM;
goto error;
}
memcpy(hif_drv->usr_conn_req.bssid, conn_attr->bssid, 6);
}

hif_drv->usr_conn_req.ssid_len = conn_attr->ssid_len;
if (conn_attr->ssid) {
hif_drv->usr_conn_req.ssid = kmalloc(conn_attr->ssid_len + 1,
GFP_KERNEL);
if (!hif_drv->usr_conn_req.ssid) {
result = -ENOMEM;
goto error;
}
memcpy(hif_drv->usr_conn_req.ssid,
conn_attr->ssid,
conn_attr->ssid_len);
Expand All @@ -961,6 +969,10 @@ static s32 handle_connect(struct wilc_vif *vif,
if (conn_attr->ies) {
hif_drv->usr_conn_req.ies = kmalloc(conn_attr->ies_len,
GFP_KERNEL);
if (!hif_drv->usr_conn_req.ies) {
result = -ENOMEM;
goto error;
}
memcpy(hif_drv->usr_conn_req.ies,
conn_attr->ies,
conn_attr->ies_len);
Expand Down

0 comments on commit aaea216

Please sign in to comment.