diff mbox

[1/3] dmaengine: pl330: Do not dereference pl330_thread pointer before non-NULL check

Message ID 1409929466-29506-1-git-send-email-k.kozlowski@samsung.com (mailing list archive)
State Superseded
Headers show

Commit Message

Krzysztof Kozlowski Sept. 5, 2014, 3:04 p.m. UTC
Do not dereference the 'struct pl330_thread *thrd' before the check for
non-NULL value.

This fixes following warning:
drivers/dma/pl330.c:1376 pl330_submit_req() warn: variable dereferenced before check 'thrd' (see line 1367)

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/dma/pl330.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Lars-Peter Clausen Sept. 5, 2014, 3:29 p.m. UTC | #1
On 09/05/2014 05:04 PM, Krzysztof Kozlowski wrote:
> Do not dereference the 'struct pl330_thread *thrd' before the check for
> non-NULL value.
>
> This fixes following warning:
> drivers/dma/pl330.c:1376 pl330_submit_req() warn: variable dereferenced before check 'thrd' (see line 1367)

I think we can just drop that whole line of checks, none of them will ever 
be true.

>
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> ---
>   drivers/dma/pl330.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
> index d5149aacd2fe..47d82070848d 100644
> --- a/drivers/dma/pl330.c
> +++ b/drivers/dma/pl330.c
> @@ -1364,7 +1364,7 @@ static inline u32 _prepare_ccr(const struct pl330_reqcfg *rqc)
>   static int pl330_submit_req(struct pl330_thread *thrd,
>   	struct dma_pl330_desc *desc)
>   {
> -	struct pl330_dmac *pl330 = thrd->dmac;
> +	struct pl330_dmac *pl330;
>   	struct _xfer_spec xs;
>   	unsigned long flags;
>   	void __iomem *regs;
> @@ -1376,6 +1376,7 @@ static int pl330_submit_req(struct pl330_thread *thrd,
>   	if (!desc || !thrd || thrd->free)
>   		return -EINVAL;
>
> +	pl330 = thrd->dmac;
>   	regs = thrd->dmac->base;
>
>   	if (pl330->state == DYING
>

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Krzysztof Kozlowski Sept. 8, 2014, 7:56 a.m. UTC | #2
On pi?, 2014-09-05 at 17:29 +0200, Lars-Peter Clausen wrote:
> On 09/05/2014 05:04 PM, Krzysztof Kozlowski wrote:
> > Do not dereference the 'struct pl330_thread *thrd' before the check for
> > non-NULL value.
> >
> > This fixes following warning:
> > drivers/dma/pl330.c:1376 pl330_submit_req() warn: variable dereferenced before check 'thrd' (see line 1367)
> 
> I think we can just drop that whole line of checks, none of them will ever 
> be true.

Sure, I'll send another version of the patch.

Thanks for review,
Krzysztof


> 
> >
> > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> > ---
> >   drivers/dma/pl330.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
> > index d5149aacd2fe..47d82070848d 100644
> > --- a/drivers/dma/pl330.c
> > +++ b/drivers/dma/pl330.c
> > @@ -1364,7 +1364,7 @@ static inline u32 _prepare_ccr(const struct pl330_reqcfg *rqc)
> >   static int pl330_submit_req(struct pl330_thread *thrd,
> >   	struct dma_pl330_desc *desc)
> >   {
> > -	struct pl330_dmac *pl330 = thrd->dmac;
> > +	struct pl330_dmac *pl330;
> >   	struct _xfer_spec xs;
> >   	unsigned long flags;
> >   	void __iomem *regs;
> > @@ -1376,6 +1376,7 @@ static int pl330_submit_req(struct pl330_thread *thrd,
> >   	if (!desc || !thrd || thrd->free)
> >   		return -EINVAL;
> >
> > +	pl330 = thrd->dmac;
> >   	regs = thrd->dmac->base;
> >
> >   	if (pl330->state == DYING
> >

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index d5149aacd2fe..47d82070848d 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -1364,7 +1364,7 @@  static inline u32 _prepare_ccr(const struct pl330_reqcfg *rqc)
 static int pl330_submit_req(struct pl330_thread *thrd,
 	struct dma_pl330_desc *desc)
 {
-	struct pl330_dmac *pl330 = thrd->dmac;
+	struct pl330_dmac *pl330;
 	struct _xfer_spec xs;
 	unsigned long flags;
 	void __iomem *regs;
@@ -1376,6 +1376,7 @@  static int pl330_submit_req(struct pl330_thread *thrd,
 	if (!desc || !thrd || thrd->free)
 		return -EINVAL;
 
+	pl330 = thrd->dmac;
 	regs = thrd->dmac->base;
 
 	if (pl330->state == DYING