Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6567860ybx; Mon, 11 Nov 2019 11:05:20 -0800 (PST) X-Google-Smtp-Source: APXvYqzTNeIAUNftruVrYp3k2b+aU+uqluMB9ueYHL0efJ50fGYhpRLMhou3V+/KHpOMEVJGJKVl X-Received: by 2002:aa7:d295:: with SMTP id w21mr27879707edq.13.1573499120434; Mon, 11 Nov 2019 11:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573499120; cv=none; d=google.com; s=arc-20160816; b=UQAzGffhziP+Ir9m1eaXqsDMPyNBPnE+ORp0vfxEJwNEuMw7EFFj7I3maisrUQ+m3K TNB9aW7coz+J79nZQaI7Sc1tdszP8IaIylNR4hnJAPPLWmCMYYoWceLxQ3SW/+1vocZn KHofy1ARFgAk+vxVO42SfvRDjgNwjL2KJDsDmr0Kx7aDXO/1mbk0B2n+PN1kGLPSgG+H FjI8SEpz4L3FS7U57gScgIligXpvS2aKwlPXlIHCJ782GH3jh27tsell35f+fZ2upL2Z R77oHak13IgPjrDLR8fdutVOLcuaVO1GIa7QVj1soRdwr1VGd59XJzEpy8I1gbJi9Dj1 FXiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2E7Pcb0Fq1DqLidt3h/x9RvZcJziUubNeMZ1c/sZOSk=; b=XqDPZfgOwCb4Z/AeJOR8VfAgTdhRJhq4qMLPdjlyxDbcWgrOPVDCxW9KCVfHMke63O rG8U7EwPBdjCet/xnlZGW4n71FM0taTTy7r41mAILA+2s2ZzwrdJFYjBHKJQvMVV1u+D TxLVUVzMEptyToXSrNLJZOtQZbVJejHyC6iAvNPBgXWsR8u68oynjoYcLZk9rZiInLio cFfRgyWLjJSjuGRFI9Nc9ZsD4atG2xKdffmEN+iFlo0KOpYYmEHE9fkVG5J0TMuLD018 AhFBIoi7J342pS1sV7YKLEjnF4gwRCxCRxMklx9iSimQjQ/Vv3eqZAjlaPLtLJRdURqb 0T7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q7uIhPXd; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si9657901ejw.142.2019.11.11.11.04.51; Mon, 11 Nov 2019 11:05:20 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=Q7uIhPXd; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729785AbfKKSoz (ORCPT + 99 others); Mon, 11 Nov 2019 13:44:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:36692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729776AbfKKSox (ORCPT ); Mon, 11 Nov 2019 13:44:53 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B15E0204FD; Mon, 11 Nov 2019 18:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497892; bh=Uwa8wS0dmARYNw/g0YO2nMdEBPNRIqFT6GX1YFH3etI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q7uIhPXdtel4naEE8llrpm8DCeoBuCgy6JGwN6z1lNZ/071dK/KRXMmp8xs2EM650 LcKSG9x07No2Elkyy4YKbsqKWzaFhV23uknEtDeMxL1TfdoyCLup5anq1ybEqC7V8e dOd1UG82r8JHu45Md81AJ8aCHA/XFks7xTQpu2EY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikhil Badola , Ran Wang , Peter Chen , Felipe Balbi , Sasha Levin Subject: [PATCH 4.19 089/125] usb: fsl: Check memory resource before releasing it Date: Mon, 11 Nov 2019 19:28:48 +0100 Message-Id: <20191111181451.931107178@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikhil Badola [ Upstream commit bc1e3a2dd0c9954fd956ac43ca2876bbea018c01 ] 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 Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- 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 be59309e848c3..d44b26d5b2a2c 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -2552,7 +2552,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.20.1