Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4072634ybg; Mon, 21 Oct 2019 03:23:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJ+7RTZfPemfAq6kfrhsFHv/XLIX3kRjy1cHNqTfwpn9c8+CvMdwmzNoteZ6Su3q5sR3EJ X-Received: by 2002:a17:906:6146:: with SMTP id p6mr9584183ejl.268.1571653380313; Mon, 21 Oct 2019 03:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571653380; cv=none; d=google.com; s=arc-20160816; b=nXTHVEz2Kzjy5rT35P6/jOqqVV4BcQ9xCc00a15NOc5KBA+cC/AMQ+FbWEnqTYW9rB OY5DqzddrSe+R57O3HpznlSGLuEbaIE5Eq76Cf3lKvspvOMwEiIa5HemVOBchhzD9iDl acP0NAwghvFmmxerh7jUoM4C7KjDt6NQIHg30hrMeID66M3g11H6lAMVJPuaelyQUwc3 HQcsusWqVLq6Z0b7yGEQKEekYLncwt8ko5rOmDILgNfhI3Z/3J1bzaGYIhRUTthdJ71y JZOq4fsLmgKs5OIt0VWa7OqsJ7zwYTDFsehd4AWIVfzgzZDJRndeZKUMHVG6kAGEXQe0 mVzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=x0WOopxc/A9EMk8a4YmCQuuS4ok+g3P2bfG0Y6XZc7I=; b=BFB4qRkGI6n/Amq601txoRjZFqN3593Wjp7AZaY5ghpAav1TPqe+9U9sZWvwSdp76U 4yPwkTC/7zMpXsLArZESJlopRfwSxegnuvsvIu99n8LEtmojaISjziZYxlDl74GtfKB0 iwM/LL/3aRkTEygVJSRywxXQkXYXX4ZXoCsvHXEI5laWimPoKgCYPI2EoOBtJvCBgoCG ceXdsqSa1nx0V4uUa/tqkM/QE7D3c4AvkbSOO+uS6+sHp1FtuiCBZGNCapo9FFACEtqp 5+Hzx6R3KgZNaKxURcixvhC5AYBOIgUOlxIEbisf8Y9vyNgaW24XXIO6nztteDWp6lxN wSxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15si9707068eda.222.2019.10.21.03.22.37; Mon, 21 Oct 2019 03:23:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbfJUKVW (ORCPT + 99 others); Mon, 21 Oct 2019 06:21:22 -0400 Received: from inva021.nxp.com ([92.121.34.21]:37094 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727110AbfJUKVV (ORCPT ); Mon, 21 Oct 2019 06:21:21 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2ACF5200527; Mon, 21 Oct 2019 12:21:20 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2E79B200509; Mon, 21 Oct 2019 12:21:15 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id BA8F8402E3; Mon, 21 Oct 2019 18:21:08 +0800 (SGT) From: Yinbo Zhu To: Li Yang , Felipe Balbi Cc: yinbo.zhu@nxp.com, xiaobo.xie@nxp.com, jiafei.pan@nxp.com, Greg Kroah-Hartman , linux-usb@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Ran Wang , Nikhil Badola Subject: [PATCH v1] usb: fsl: Check memory resource before releasing it Date: Mon, 21 Oct 2019 18:21:51 +0800 Message-Id: <20191021102153.16435-1-yinbo.zhu@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikhil Badola Check memory resource existence before releasing it to avoid NULL pointer dereference Signed-off-by: Nikhil Badola Reviewed-by: Ran Wang Reviewed-by: Peter Chen --- drivers/usb/gadget/udc/fsl_udc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index 20141c3096f6..9a05863b2876 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -2576,7 +2576,7 @@ static int fsl_udc_remove(struct platform_device *pdev) dma_pool_destroy(udc_controller->td_pool); free_irq(udc_controller->irq, udc_controller); iounmap(dr_regs); - if (pdata->operating_mode == FSL_USB2_DR_DEVICE) + if (res && (pdata->operating_mode == FSL_USB2_DR_DEVICE)) release_mem_region(res->start, resource_size(res)); /* free udc --wait for the release() finished */ -- 2.17.1