Skip to content

Commit c9a9e0a

Browse files
Loic Poulainnashif
authored andcommitted
drivers: wifi: eswifi: Fix coverity issues
This patch fixes the following issues: CID 190622 (#1 of 1): Out-of-bounds access (OVERRUN) CID 190632 (#1 of 1): Out-of-bounds access (OVERRUN) CID 190623 (#1 of 1): Unchecked return value (CHECKED_RETURN) CID 190628 (#1 of 1): Out-of-bounds write (OVERRUN) CID 190620 (#1 of 1): Dereference after null check (FORWARD_NULL) Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
1 parent b04e719 commit c9a9e0a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

drivers/wifi/eswifi/eswifi_core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ static int eswifi_reset(struct eswifi_dev *eswifi)
4545
k_sleep(500);
4646

4747
/* fetch the cursor */
48-
eswifi_request(eswifi, NULL, 0, eswifi->buf, sizeof(eswifi->buf));
49-
50-
return 0;
48+
return eswifi_request(eswifi, NULL, 0, eswifi->buf,
49+
sizeof(eswifi->buf));
5150
}
5251

5352
static inline int __parse_ssid(char *str, char *ssid)
@@ -328,7 +327,7 @@ static int eswifi_get_mac_addr(struct eswifi_dev *eswifi, u8_t addr[6])
328327
return err;
329328
}
330329

331-
for (i = 0; i < sizeof(eswifi->buf); i++) {
330+
for (i = 0; i < sizeof(eswifi->buf) && byte < 6; i++) {
332331
if (i < 2) {
333332
continue;
334333
}
@@ -466,6 +465,7 @@ static int eswifi_init(struct device *dev)
466465
if (!eswifi->resetn.dev) {
467466
LOG_ERR("Failed to initialize GPIO driver: %s",
468467
DT_INVENTEK_ESWIFI_ESWIFI0_RESETN_GPIOS_CONTROLLER);
468+
return -ENODEV;
469469
}
470470
eswifi->resetn.pin = DT_INVENTEK_ESWIFI_ESWIFI0_RESETN_GPIOS_PIN;
471471
gpio_pin_configure(eswifi->resetn.dev, eswifi->resetn.pin,
@@ -476,6 +476,7 @@ static int eswifi_init(struct device *dev)
476476
if (!eswifi->wakeup.dev) {
477477
LOG_ERR("Failed to initialize GPIO driver: %s",
478478
DT_INVENTEK_ESWIFI_ESWIFI0_WAKEUP_GPIOS_CONTROLLER);
479+
return -ENODEV;
479480
}
480481
eswifi->wakeup.pin = DT_INVENTEK_ESWIFI_ESWIFI0_WAKEUP_GPIOS_PIN;
481482
gpio_pin_configure(eswifi->wakeup.dev, eswifi->wakeup.pin,

drivers/wifi/eswifi/eswifi_offload.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int __read_data(struct eswifi_dev *eswifi, size_t len)
4343
int err, i, read = 0;
4444

4545
/* Set max read size */
46-
snprintf(size, sizeof(eswifi->buf), "R1=%u\r", len);
46+
snprintf(size, sizeof(size), "R1=%u\r", len);
4747
err = eswifi_request(eswifi, size, strlen(size),
4848
eswifi->buf, sizeof(eswifi->buf));
4949
if (err || !eswifi_is_buf_at_ok(eswifi->buf)) {
@@ -52,7 +52,7 @@ static int __read_data(struct eswifi_dev *eswifi, size_t len)
5252
}
5353

5454
/* Set timeout */
55-
snprintf(timeout, sizeof(eswifi->buf), "R2=%u\r", 30); /* 30 ms */
55+
snprintf(timeout, sizeof(timeout), "R2=%u\r", 30); /* 30 ms */
5656
err = eswifi_request(eswifi, timeout, strlen(timeout),
5757
eswifi->buf, sizeof(eswifi->buf));
5858
if (err || !eswifi_is_buf_at_ok(eswifi->buf)) {

0 commit comments

Comments
 (0)