drivers/usb/chipidea/usbmisc_imx.c:745 imx7d_charger_data_contact_detect() error: double unlocked 'usbmisc->lock' (orig line 725)

From: kernel test robot
Date: Tue Aug 11 2020 - 16:58:14 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 00e4db51259a5f936fec1424b884f029479d3981
commit: 746f316b753a83e366bfc5f936cbf0d72d1c2d1d usb: chipidea: introduce imx7d USB charger detection
date: 3 months ago
config: h8300-randconfig-m031-20200811 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

smatch warnings:
drivers/usb/chipidea/usbmisc_imx.c:745 imx7d_charger_data_contact_detect() error: double unlocked 'usbmisc->lock' (orig line 725)

vim +745 drivers/usb/chipidea/usbmisc_imx.c

712
713 static int imx7d_charger_data_contact_detect(struct imx_usbmisc_data *data)
714 {
715 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
716 unsigned long flags;
717 u32 val;
718 int i, data_pin_contact_count = 0;
719
720 /* Enable Data Contact Detect (DCD) per the USB BC 1.2 */
721 spin_lock_irqsave(&usbmisc->lock, flags);
722 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
723 writel(val | MX7D_USB_OTG_PHY_CFG2_CHRG_DCDENB,
724 usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
> 725 spin_unlock_irqrestore(&usbmisc->lock, flags);
726
727 for (i = 0; i < 100; i = i + 1) {
728 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS);
729 if (!(val & MX7D_USB_OTG_PHY_STATUS_LINE_STATE0)) {
730 if (data_pin_contact_count++ > 5)
731 /* Data pin makes contact */
732 break;
733 usleep_range(5000, 10000);
734 } else {
735 data_pin_contact_count = 0;
736 usleep_range(5000, 6000);
737 }
738 }
739
740 /* Disable DCD after finished data contact check */
741 spin_lock_irqsave(&usbmisc->lock, flags);
742 val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
743 writel(val & ~MX7D_USB_OTG_PHY_CFG2_CHRG_DCDENB,
744 usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
> 745 spin_unlock_irqrestore(&usbmisc->lock, flags);
746
747 if (i == 100) {
748 dev_err(data->dev,
749 "VBUS is coming from a dedicated power supply.\n");
750 return -ENXIO;
751 }
752
753 return 0;
754 }
755

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip