[PATCH 4.17 267/336] staging: ks7010: fix error handling in ks7010_upload_firmware

From: Greg Kroah-Hartman
Date: Wed Aug 01 2018 - 14:29:42 EST


4.17-stable review patch. If anyone has any objections, please let me know.

------------------

From: Sergio Paracuellos <sergio.paracuellos@xxxxxxxxx>

[ Upstream commit 6e043704fb99e3e1d7a1bb02030e49c093cdd943 ]

This commit checks missing error code check when checking
if the firmware is running reading General Communication
Register A (GCR_A).

It also set ret to EBUSY if firmware is running before
copying it.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@xxxxxxxxx>
Reviewed-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/staging/ks7010/ks7010_sdio.c | 3 +++
1 file changed, 3 insertions(+)

--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -657,8 +657,11 @@ static int ks7010_upload_firmware(struct

/* Firmware running ? */
ret = ks7010_sdio_readb(priv, GCR_A, &byte);
+ if (ret)
+ goto release_host_and_free;
if (byte == GCR_A_RUN) {
netdev_dbg(priv->net_dev, "MAC firmware running ...\n");
+ ret = -EBUSY;
goto release_host_and_free;
}