diff mbox

lightnvm: pblk: remove some unnecessary NULL checks

Message ID 20171106114843.7rs6myhgxgij3jh7@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Nov. 6, 2017, 11:48 a.m. UTC
Smatch complains that flush_workqueue() dereferences the work queue
pointer but then we check if it's NULL on the next line when it's too
late.  These NULL checks can be removed because the module won't load if
we can't allocate the work queues.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Matias Bjorling Dec. 20, 2017, 5:30 p.m. UTC | #1
On 11/06/2017 12:48 PM, Dan Carpenter wrote:
> Smatch complains that flush_workqueue() dereferences the work queue
> pointer but then we check if it's NULL on the next line when it's too
> late.  These NULL checks can be removed because the module won't load if
> we can't allocate the work queues.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c
> index 00d5698d64a9..aaba2049a135 100644
> --- a/drivers/lightnvm/pblk-gc.c
> +++ b/drivers/lightnvm/pblk-gc.c
> @@ -669,12 +669,10 @@ void pblk_gc_exit(struct pblk *pblk)
>   		kthread_stop(gc->gc_reader_ts);
>   
>   	flush_workqueue(gc->gc_reader_wq);
> -	if (gc->gc_reader_wq)
> -		destroy_workqueue(gc->gc_reader_wq);
> +	destroy_workqueue(gc->gc_reader_wq);
>   
>   	flush_workqueue(gc->gc_line_reader_wq);
> -	if (gc->gc_line_reader_wq)
> -		destroy_workqueue(gc->gc_line_reader_wq);
> +	destroy_workqueue(gc->gc_line_reader_wq);
>   
>   	if (gc->gc_writer_ts)
>   		kthread_stop(gc->gc_writer_ts);
> 

Thanks Dan. I've applied it for 4.16.
diff mbox

Patch

diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c
index 00d5698d64a9..aaba2049a135 100644
--- a/drivers/lightnvm/pblk-gc.c
+++ b/drivers/lightnvm/pblk-gc.c
@@ -669,12 +669,10 @@  void pblk_gc_exit(struct pblk *pblk)
 		kthread_stop(gc->gc_reader_ts);
 
 	flush_workqueue(gc->gc_reader_wq);
-	if (gc->gc_reader_wq)
-		destroy_workqueue(gc->gc_reader_wq);
+	destroy_workqueue(gc->gc_reader_wq);
 
 	flush_workqueue(gc->gc_line_reader_wq);
-	if (gc->gc_line_reader_wq)
-		destroy_workqueue(gc->gc_line_reader_wq);
+	destroy_workqueue(gc->gc_line_reader_wq);
 
 	if (gc->gc_writer_ts)
 		kthread_stop(gc->gc_writer_ts);