From 813b74096e792c9265dc34fabf573102b173ae6d Mon Sep 17 00:00:00 2001 From: Gidon Studinski Date: Tue, 19 Nov 2019 12:34:14 +0200 Subject: [PATCH] wigig_sensing: return error code after change_mode failure change_mode command sometimes fail. In such a case, a proper error code should be returned to the calling user space application. Otherwise, the application tries to read data, which is not available. Change-Id: I03778cace54fd98847a099bbeaf7884cfbaac586 Signed-off-by: Gidon Studinski Signed-off-by: Alexei Avshalom Lazar --- drivers/misc/wigig_sensing.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/misc/wigig_sensing.c b/drivers/misc/wigig_sensing.c index e3758b116338..059676600ab2 100644 --- a/drivers/misc/wigig_sensing.c +++ b/drivers/misc/wigig_sensing.c @@ -546,7 +546,8 @@ static int wigig_sensing_ioc_change_mode(struct wigig_sensing_ctx *ctx, int rc; u32 ch; - pr_info("mode = %d, channel = %d\n", req.mode, req.channel); + pr_info("mode = %d, channel = %d, has_channel = %d\n", + req.mode, req.channel, req.has_channel); if (!ctx) return -EINVAL; @@ -583,12 +584,13 @@ static int wigig_sensing_ioc_change_mode(struct wigig_sensing_ctx *ctx, /* Interrupted by a signal */ pr_err("wait_event_interruptible_timeout() interrupted by a signal (%d)\n", rc); - return rc; + goto End; } if (rc == 0) { /* Timeout, FW did not respond in time */ pr_err("wait_event_interruptible_timeout() timed out\n"); - return -ETIME; + rc = -ETIME; + goto End; } /* Change internal state */ @@ -605,7 +607,8 @@ static int wigig_sensing_ioc_change_mode(struct wigig_sensing_ctx *ctx, ctx->stm.change_mode_in_progress = false; End: - return ctx->stm.burst_size; + ctx->stm.change_mode_in_progress = false; + return (rc == 0) ? ctx->stm.burst_size : rc; } static int wigig_sensing_ioc_clear_data(struct wigig_sensing_ctx *ctx)