From e21a447a5185fd5ae65dcd00e46b1260dd200e3b Mon Sep 17 00:00:00 2001 From: Sreelakshmi Gownipalli Date: Thu, 1 Aug 2019 15:44:58 -0700 Subject: [PATCH] diag: Donot queue read in error case during mhi diag open Donot queue any mhi diag read work when there is an error while opening mhi diag channels. Change-Id: Ie4a058b755dbdba7a3d12a19aebdc8f2e059e8ae Signed-off-by: Sreelakshmi Gownipalli --- drivers/char/diag/diagfwd_mhi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/char/diag/diagfwd_mhi.c b/drivers/char/diag/diagfwd_mhi.c index 11355bd564726..bd6772e9ebc37 100644 --- a/drivers/char/diag/diagfwd_mhi.c +++ b/drivers/char/diag/diagfwd_mhi.c @@ -320,6 +320,8 @@ static int __mhi_open(struct diag_mhi_info *mhi_info, int open_flag) static int mhi_open(int id) { + int err = 0; + if (id < 0 || id >= NUM_MHI_DEV) { pr_err("diag: In %s, invalid index %d\n", __func__, id); return -EINVAL; @@ -330,7 +332,9 @@ static int mhi_open(int id) * explicitly by Diag. Open both the read and write channels (denoted by * OPEN_CHANNELS flag) */ - __mhi_open(&diag_mhi[id], OPEN_CHANNELS); + err = __mhi_open(&diag_mhi[id], OPEN_CHANNELS); + if (err) + return err; diag_remote_dev_open(diag_mhi[id].dev_id); queue_work(diag_mhi[id].mhi_wq, &(diag_mhi[id].read_work));