[next] dm delay: Fix missing error code in delay_ctr()

Message ID 20231031071000.374939-1-harshit.m.mogalapalli@oracle.com
State New
Headers
Series [next] dm delay: Fix missing error code in delay_ctr() |

Commit Message

Harshit Mogalapalli Oct. 31, 2023, 7:10 a.m. UTC
  When worker thread allocation fails, return error instead of
zero(success).

Also when kthread_create fails it returns ERR pointers and not NULL, so
fix that as well.

Fixes: c1fce71d29b2 ("dm delay: for short delays, use kthread instead of timers and wq")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
Smatch complained about the missing error code.
This patch is only compile tested.
---
 drivers/md/dm-delay.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Christian Loehle Oct. 31, 2023, 9:35 a.m. UTC | #1
On 31/10/2023 07:10, Harshit Mogalapalli wrote:
> When worker thread allocation fails, return error instead of
> zero(success).
> 
> Also when kthread_create fails it returns ERR pointers and not NULL, so
> fix that as well.
> 
> Fixes: c1fce71d29b2 ("dm delay: for short delays, use kthread instead of timers and wq")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> Smatch complained about the missing error code.
> This patch is only compile tested.
> ---
>  drivers/md/dm-delay.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
> index 3d91804923eb..efd510984e25 100644
> --- a/drivers/md/dm-delay.c
> +++ b/drivers/md/dm-delay.c
> @@ -280,8 +280,10 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>  		 */
>  		dc->worker = kthread_create(&flush_worker_fn, dc,
>  					    "dm-delay-flush-worker");
> -		if (!dc->worker)
> +		if (IS_ERR(dc->worker)) {
> +			ret = PTR_ERR(dc->worker);
>  			goto bad;
> +		}
>  	} else {
>  		timer_setup(&dc->delay_timer, handle_delayed_timer, 0);
>  		INIT_WORK(&dc->flush_expired_bios, flush_expired_bios);
Reviewed-by: Christian Loehle <christian.loehle@arm.com>

Thanks!
  

Patch

diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
index 3d91804923eb..efd510984e25 100644
--- a/drivers/md/dm-delay.c
+++ b/drivers/md/dm-delay.c
@@ -280,8 +280,10 @@  static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 		 */
 		dc->worker = kthread_create(&flush_worker_fn, dc,
 					    "dm-delay-flush-worker");
-		if (!dc->worker)
+		if (IS_ERR(dc->worker)) {
+			ret = PTR_ERR(dc->worker);
 			goto bad;
+		}
 	} else {
 		timer_setup(&dc->delay_timer, handle_delayed_timer, 0);
 		INIT_WORK(&dc->flush_expired_bios, flush_expired_bios);