Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: cdnsp: Fix segmentation fault in cdns_lost_power function

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>
Link: https://lore.kernel.org/r/20220111090737.10345-1-pawell@gli-login.cadence.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Pawel Laszczak and committed by
Greg Kroah-Hartman
79aa3e19 ac55d163

+3 -3
+3 -3
drivers/usb/cdns3/drd.c
··· 483 483 /* Indicate the cdns3 core was power lost before */ 484 484 bool cdns_power_is_lost(struct cdns *cdns) 485 485 { 486 - if (cdns->version == CDNS3_CONTROLLER_V1) { 487 - if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0))) 486 + if (cdns->version == CDNS3_CONTROLLER_V0) { 487 + if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) 488 488 return true; 489 489 } else { 490 - if (!(readl(&cdns->otg_v0_regs->simulate) & BIT(0))) 490 + if (!(readl(&cdns->otg_v1_regs->simulate) & BIT(0))) 491 491 return true; 492 492 } 493 493 return false;