All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pawel Laszczak <pawell@cadence.com>
To: Peter Chen <peter.chen@kernel.org>
Cc: "a-govindraju@ti.com" <a-govindraju@ti.com>,
	"frank.li@nxp.com" <frank.li@nxp.com>,
	"rogerq@kernel.org" <rogerq@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] usb: cdnsp: Fix segmentation fault in cdns_lost_power function
Date: Wed, 12 Jan 2022 13:13:10 +0000	[thread overview]
Message-ID: <BYAPR07MB5381D8455AF977200D503D15DD529@BYAPR07MB5381.namprd07.prod.outlook.com> (raw)
In-Reply-To: <20220112125615.GC3796@Peter>

>
>On 22-01-11 10:07:37, Pawel Laszczak wrote:
>> From: Pawel Laszczak <pawell@cadence.com>
>>
>> CDNSP driver read not initialized cdns->otg_v0_regs
>> which lead to segmentation fault. Patch fixes this issue.
>>
>> Fixes: 2cf2581cd229 ("usb: cdns3: add power lost support for system resume")
>> cc: <stable@vger.kernel.org>
>> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>> ---
>>  drivers/usb/cdns3/drd.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c
>> index 55c73b1d8704..d00ff98dffab 100644
>> --- a/drivers/usb/cdns3/drd.c
>> +++ b/drivers/usb/cdns3/drd.c
>> @@ -483,11 +483,11 @@ int cdns_drd_exit(struct cdns *cdns)
>>  /* Indicate the cdns3 core was power lost before */
>>  bool cdns_power_is_lost(struct cdns *cdns)
>>  {
>> -	if (cdns->version == CDNS3_CONTROLLER_V1) {
>> -		if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0)))
>> +	if (cdns->version == CDNS3_CONTROLLER_V0) {
>> +		if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0)))
>>  			return true;
>>  	} else {
>> -		if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0)))
>> +		if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0)))
>>  			return true;
>>  	}
>>  	return false;
>> --
>
>Pawel, may this lead cdns driver segment fault?
>

Yes, we can observe such situation for CDNSP driver on simulation. 
As you know, it is a common code and driver support two version  of register map for DRD.

If cdns->version  == CDNSP_CONTROLLER_V2 (for CNDSP) the cdns->otg_v0_regs is NULL.
It will cause segmentation fault. 

I didn't analyze why this issue was not observed on my FPGA testing board.

Regards,

Pawel Laszczak  

      reply	other threads:[~2022-01-12 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11  9:07 [PATCH] usb: cdnsp: Fix segmentation fault in cdns_lost_power function Pawel Laszczak
2022-01-12 12:56 ` Peter Chen
2022-01-12 13:13   ` Pawel Laszczak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BYAPR07MB5381D8455AF977200D503D15DD529@BYAPR07MB5381.namprd07.prod.outlook.com \
    --to=pawell@cadence.com \
    --cc=a-govindraju@ti.com \
    --cc=frank.li@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@kernel.org \
    --cc=rogerq@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.