mei: hbm: fix client dma reply status
Subsystems (3)
From: Alexander Usyskin <[email protected]>
Don't blindly copy status value received from the firmware into internal client status field,
It may be positive and ERR_PTR(ret) will translate it into an invalid address and the caller will crash.
Put the error code into the client status on failure.
Fixes 369aea845951 ("mei: implement client dma setup.")
Reported-by Emmanuel Grumbach <[email protected]>
Cc <[email protected]> # v5.11+
Acked-by Tomas Winkler <[email protected]>
Signed-off-by Alexander Usyskin <[email protected]>
Signed-off-by Tomas Winkler <[email protected]>
--- drivers/misc/mei/hbm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/misc/mei/hbm.c +14 -6
@@ -672,10 +672,14 @@ static void mei_hbm_cl_dma_map_res(struct mei_device *dev,if (!cl)return ; -dev_dbg (dev->dev,"cl dma map result = %d\n" , res->status); - cl->status = res->status; -if (!cl->status) +if (res->status) { +dev_err (dev->dev,"cl dma map failed %d\n" , res->status); + cl->status = -EFAULT ; + }else { +dev_dbg (dev->dev,"cl dma map succeeded\n" ); cl->dma_mapped =1 ; + cl->status =0 ; + }wake_up (&cl->wait); }
@@ -698,10 +702,14 @@ static void mei_hbm_cl_dma_unmap_res(struct mei_device *dev,if (!cl)return ; -dev_dbg (dev->dev,"cl dma unmap result = %d\n" , res->status); - cl->status = res->status; -if (!cl->status) +if (res->status) { +dev_err (dev->dev,"cl dma unmap failed %d\n" , res->status); + cl->status = -EFAULT ; + }else { +dev_dbg (dev->dev,"cl dma unmap succeeded\n" ); cl->dma_mapped =0 ; + cl->status =0 ; + }wake_up (&cl->wait); }
Signature · 1 line
2.31.1
Grumbach, Emmanuel
Tested-byQuoted 7 lines
From: Alexander Usyskin <[email protected]>
Don't blindly copy status value received from the firmware into internal client status field, It may be positive and
ERR_PTR(ret)will translate it into an invalid address and the caller will crash.
Quoted 9 lines
Put the error code into the client status on failure.
Fixes 369aea845951 ("mei: implement client dma setup.")Reported-by Emmanuel Grumbach <[email protected]>Cc <[email protected]> # v5.11+Acked-by Tomas Winkler <[email protected]>Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>
Tested-by : Emmanuel Grumbach <[email protected]>