From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Chancellor Subject: Re: [PATCH] scsi: gdth: Only call dma_free_coherent when buf is not NULL in ioc_general Date: Wed, 20 Mar 2019 12:12:38 -0700 Message-ID: <20190320191238.GF28744@archlinux-ryzen> References: <20190307231839.3330-1-natechancellor@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190307231839.3330-1-natechancellor@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: "James E.J. Bottomley" , "Martin K. Petersen" , Achim Leubner Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nick Desaulniers , Christoph Hellwig List-Id: linux-scsi@vger.kernel.org On Thu, Mar 07, 2019 at 04:18:39PM -0700, Nathan Chancellor wrote: > When building with -Wsometimes-uninitialized, Clang warns: > > drivers/scsi/gdth.c:3662:6: warning: variable 'paddr' is used > uninitialized whenever 'if' condition is false > [-Wsometimes-uninitialized] > > Don't attempt to call dma_free_coherent when buf is NULL (meaning that > we never called dma_alloc_coherent and initialized paddr), which avoids > this warning. > > Link: https://github.com/ClangBuiltLinux/linux/issues/402 > Signed-off-by: Nathan Chancellor > --- > drivers/scsi/gdth.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c > index e7f1dd4f3b66..0ca9b4393770 100644 > --- a/drivers/scsi/gdth.c > +++ b/drivers/scsi/gdth.c > @@ -3697,8 +3697,9 @@ static int ioc_general(void __user *arg, char *cmnd) > > rval = 0; > out_free_buf: > - dma_free_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len, buf, > - paddr); > + if (buf) > + dma_free_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len, > + buf, paddr); > return rval; > } > > -- > 2.21.0 > Gentle ping (if there was a response to this, I didn't receive it). I know I sent it in the middle of a merge window so I get if it slipped through the cracks. Thanks, Nathan