gru: unlocking should be conditional in gru_dump_context()
Subsystems (2)
PATCH 1/2 gru: unlocking should be conditional in gru_dump_context()
I was reviewing this and noticed that unlocking should be conditional on the error path. I've changed it to unlock and return directly since we only do it once and it seems unlikely to change in the near future.
Signed-off-by Dan Carpenter <[email protected]>
drivers/misc/sgi-gru/grukdump.c +5 -6
@@ -139,8 +139,11 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum, ubuf +=sizeof (hdr); ubufcch = ubuf; -if (gru_user_copy_handle (&ubuf, cch)) - goto fail; +if (gru_user_copy_handle (&ubuf, cch)) { +if (cch_locked) +unlock_cch_handle (cch); +return -EFAULT ; + }if (cch_locked) ubufcch->delresp =0 ; bytes =sizeof (hdr) +GRU_CACHE_LINE_BYTES ;
@@ -179,10 +182,6 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum, ret = -EFAULT ;return ret ? ret : bytes; - -fail: -unlock_cch_handle (cch); -return -EFAULT ; }int gru_dump_chiplet_request (unsigned long arg)
Acked-by Dimitri Sivanich <[email protected]>
Quoted 35 lines · Dan Carpenter
I was reviewing this and noticed that unlocking should be conditional on the error path. I've changed it to unlock and return directly since we only do it once and it seems unlikely to change in the near future.
Signed-off-by Dan Carpenter <[email protected]>drivers/misc/sgi-gru/grukdump.c +5
-6@@ -139,8 +139,11 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum, ubuf +=sizeof (hdr); ubufcch = ubuf; -if (gru_user_copy_handle (&ubuf, cch)) - goto fail; +if (gru_user_copy_handle (&ubuf, cch)) { +if (cch_locked) +unlock_cch_handle (cch); +return -EFAULT ; + }if (cch_locked) ubufcch->delresp =0 ; bytes =sizeof (hdr) +GRU_CACHE_LINE_BYTES ;@@ -179,10 +182,6 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum, ret = -EFAULT ;return ret ? ret : bytes; - -fail: -unlock_cch_handle (cch); -return -EFAULT ; }int gru_dump_chiplet_request (unsigned long arg)