ath10k: fix a NULL vs IS_ERR() check
diff mbox series

Message ID 20181126081143.tvu55aimdc3safcq@kili.mountain
State New
Headers show
Series
  • ath10k: fix a NULL vs IS_ERR() check
Related show

Commit Message

Dan Carpenter Nov. 26, 2018, 8:11 a.m. UTC
The devm_memremap() function doesn't return NULLs, it returns error
pointers.

Fixes: ba94c753ccb4 ("ath10k: add QMI message handshake for wcn3990 client")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/wireless/ath/ath10k/qmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kalle Valo Nov. 26, 2018, 8:24 a.m. UTC | #1
Dan Carpenter <dan.carpenter@oracle.com> writes:

> The devm_memremap() function doesn't return NULLs, it returns error
> pointers.
>
> Fixes: ba94c753ccb4 ("ath10k: add QMI message handshake for wcn3990 client")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/wireless/ath/ath10k/qmi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
> index f0429bee35c2..37b3bd629f48 100644
> --- a/drivers/net/wireless/ath/ath10k/qmi.c
> +++ b/drivers/net/wireless/ath/ath10k/qmi.c
> @@ -931,9 +931,9 @@ static int ath10k_qmi_setup_msa_resources(struct ath10k_qmi *qmi, u32 msa_size)
>  		qmi->msa_mem_size = resource_size(&r);
>  		qmi->msa_va = devm_memremap(dev, qmi->msa_pa, qmi->msa_mem_size,
>  					    MEMREMAP_WT);
> -		if (!qmi->msa_va) {
> +		if (IS_ERR(qmi->msa_va)) {
>  			dev_err(dev, "failed to map memory region: %pa\n", &r.start);
> -			return -EBUSY;
> +			return PTR_ERR(qmi->msa_va);

That's a very good find!

But how has this even worked before? I would assume devm_memremap()
always returns a non-NULL value and ath10k would have interpreted that
as an error?
Dan Carpenter Nov. 26, 2018, 8:30 a.m. UTC | #2
On Mon, Nov 26, 2018 at 10:24:38AM +0200, Kalle Valo wrote:
> Dan Carpenter <dan.carpenter@oracle.com> writes:
> 
> > The devm_memremap() function doesn't return NULLs, it returns error
> > pointers.
> >
> > Fixes: ba94c753ccb4 ("ath10k: add QMI message handshake for wcn3990 client")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> >  drivers/net/wireless/ath/ath10k/qmi.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
> > index f0429bee35c2..37b3bd629f48 100644
> > --- a/drivers/net/wireless/ath/ath10k/qmi.c
> > +++ b/drivers/net/wireless/ath/ath10k/qmi.c
> > @@ -931,9 +931,9 @@ static int ath10k_qmi_setup_msa_resources(struct ath10k_qmi *qmi, u32 msa_size)
> >  		qmi->msa_mem_size = resource_size(&r);
> >  		qmi->msa_va = devm_memremap(dev, qmi->msa_pa, qmi->msa_mem_size,
> >  					    MEMREMAP_WT);
> > -		if (!qmi->msa_va) {
> > +		if (IS_ERR(qmi->msa_va)) {
> >  			dev_err(dev, "failed to map memory region: %pa\n", &r.start);
> > -			return -EBUSY;
> > +			return PTR_ERR(qmi->msa_va);
> 
> That's a very good find!
> 
> But how has this even worked before?

This only changes the error path.  Presumably it always succeeds in real
life.

regards,
dan carpenter
Kalle Valo Nov. 26, 2018, 1:06 p.m. UTC | #3
Dan Carpenter <dan.carpenter@oracle.com> writes:

> On Mon, Nov 26, 2018 at 10:24:38AM +0200, Kalle Valo wrote:
>> Dan Carpenter <dan.carpenter@oracle.com> writes:
>> 
>> > The devm_memremap() function doesn't return NULLs, it returns error
>> > pointers.
>> >
>> > Fixes: ba94c753ccb4 ("ath10k: add QMI message handshake for wcn3990 client")
>> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> > ---
>> >  drivers/net/wireless/ath/ath10k/qmi.c | 4 ++--
>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
>> > index f0429bee35c2..37b3bd629f48 100644
>> > --- a/drivers/net/wireless/ath/ath10k/qmi.c
>> > +++ b/drivers/net/wireless/ath/ath10k/qmi.c
>> > @@ -931,9 +931,9 @@ static int ath10k_qmi_setup_msa_resources(struct ath10k_qmi *qmi, u32 msa_size)
>> >  		qmi->msa_mem_size = resource_size(&r);
>> >  		qmi->msa_va = devm_memremap(dev, qmi->msa_pa, qmi->msa_mem_size,
>> >  					    MEMREMAP_WT);
>> > -		if (!qmi->msa_va) {
>> > +		if (IS_ERR(qmi->msa_va)) {
>> >  			dev_err(dev, "failed to map memory region: %pa\n", &r.start);
>> > -			return -EBUSY;
>> > +			return PTR_ERR(qmi->msa_va);
>> 
>> That's a very good find!
>> 
>> But how has this even worked before?
>
> This only changes the error path.  Presumably it always succeeds in real
> life.

Ah, I missed the "!" operator. Yeah, I think you are correct. I'll queue
this for -next then.
Kalle Valo Dec. 20, 2018, 5:05 p.m. UTC | #4
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The devm_memremap() function doesn't return NULLs, it returns error
> pointers.
> 
> Fixes: ba94c753ccb4 ("ath10k: add QMI message handshake for wcn3990 client")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

Patch applied to ath-next branch of ath.git, thanks.

c28dcbce0592 ath10k: fix a NULL vs IS_ERR() check

Patch
diff mbox series

diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
index f0429bee35c2..37b3bd629f48 100644
--- a/drivers/net/wireless/ath/ath10k/qmi.c
+++ b/drivers/net/wireless/ath/ath10k/qmi.c
@@ -931,9 +931,9 @@  static int ath10k_qmi_setup_msa_resources(struct ath10k_qmi *qmi, u32 msa_size)
 		qmi->msa_mem_size = resource_size(&r);
 		qmi->msa_va = devm_memremap(dev, qmi->msa_pa, qmi->msa_mem_size,
 					    MEMREMAP_WT);
-		if (!qmi->msa_va) {
+		if (IS_ERR(qmi->msa_va)) {
 			dev_err(dev, "failed to map memory region: %pa\n", &r.start);
-			return -EBUSY;
+			return PTR_ERR(qmi->msa_va);
 		}
 	} else {
 		qmi->msa_va = dmam_alloc_coherent(dev, msa_size,