Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp738307pxu; Mon, 23 Nov 2020 02:55:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXAXWmZTL044QIWkb5UwxyEQOt3uWoESMWP4zoNzGcuK3jCJWM+mUdf0n4p/I6yVVtKoqr X-Received: by 2002:a17:906:7087:: with SMTP id b7mr11184322ejk.70.1606128911440; Mon, 23 Nov 2020 02:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606128911; cv=none; d=google.com; s=arc-20160816; b=w4wbEH3AFvR9R7eE4uiHhi+VKIY5MqwPl9q5IW26lVTSa5XlZLV3qzJXEI4uY1zpl9 MVGNaIxrCUmdlRoLDg7pV9tyJHzm7CGSlXlJNwDr1ognWYrHngDu2606gTFN9CWG3ed2 8KIEgPPoBa58h+Ysen8PwHJBF5mvXGbnZiGCVnQO8PM7qP3PvmXms5dknR91to1dthT4 jR5NAiSh8JxzNS2u560cbNI/hzzrb9qlF4Gwa2cXBQY+dpRtJvgsfAsfNRnr35idvTDE 4UpXpMReL6leD2ikYX8rvJFYdxPmifisUVZky11vmaJSWTCvtp9VtXPZK9C2KDI9BIXB G9Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=doxgCA0KKX7am9PImJvHoj3LukpJfzg33PGccXuEGq0=; b=VKm6cOHdhrn5kpkPmXvam6Tvv+h3mSXzENCURvl8vkaPq1QpIf5+v1P/VB6LAU9tci W/mOzAfZc2m2/faiR1KR6oo8kIjPT6/Fvsc2Ofnoh90dU+pjaun9uvMR5l++Y3pLdKXg 336rAbUE+y9LPYqM5q3Nl6X6TaMyl3RajhizDIh/tx7E2TnVhe9ULnwL1mQhUSuFS3ZQ FDN/rzrbzCDPMutIubNroRjxDrIxhE327rZxyNN6+uZpA50aIphEtbXqx6uOYlnix6rU 2RpvdOptrVUlZMTskkj6oK/8u3d+7MJ8Es2+mCJrYAH5bBgPzUw1YXE1iVPHij683xRg ck8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DXwH3L8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si4862237edi.447.2020.11.23.02.54.48; Mon, 23 Nov 2020 02:55:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DXwH3L8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbgKWKtm (ORCPT + 99 others); Mon, 23 Nov 2020 05:49:42 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:55150 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728523AbgKWKtm (ORCPT ); Mon, 23 Nov 2020 05:49:42 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0ANAnauO062166; Mon, 23 Nov 2020 04:49:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1606128576; bh=doxgCA0KKX7am9PImJvHoj3LukpJfzg33PGccXuEGq0=; h=From:To:CC:Subject:Date; b=DXwH3L8qePkyPs69vDlSaIo0ZjaFKeTTDMfG/PV9oC1uhSF+BgWP7CnZ04oCZtmEs diy6hYWmlV77r300iC2IeJAIEWmah5gvOW3puZpg/3AvjLgiCBwbz7z6PxXMka6DQh Rp8ELwidahXbBBZoDTMv22ARq04lfJ9Hbih+vtQU= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0ANAna9n115464 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 23 Nov 2020 04:49:36 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Mon, 23 Nov 2020 04:49:36 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Mon, 23 Nov 2020 04:49:36 -0600 Received: from lta0400828a.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0ANAnXQq028102; Mon, 23 Nov 2020 04:49:34 -0600 From: Roger Quadros To: , CC: , , , , , , Roger Quadros Subject: [PATCH] usb: cdns3: fix NULL pointer dereference on no platform data Date: Mon, 23 Nov 2020 12:49:31 +0200 Message-ID: <20201123104931.2653-1-rogerq@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some platforms (e.g. TI) will not have any platform data which will lead to NULL pointer dereference if we don't check for NULL pdata. Fixes: a284b7fd1b8f ("usb: cdns3: add quirk for enable runtime pm by default") Reported-by: Nishanth Menon Signed-off-by: Roger Quadros --- drivers/usb/cdns3/core.c | 2 +- drivers/usb/cdns3/host.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 54d841aa626f..0f08aebce86d 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -559,7 +559,7 @@ static int cdns3_probe(struct platform_device *pdev) device_set_wakeup_capable(dev, true); pm_runtime_set_active(dev); pm_runtime_enable(dev); - if (!(cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW)) + if (!(cdns->pdata && (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW))) pm_runtime_forbid(dev); /* diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index 08103785a17a..ec89f2e5430f 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -59,7 +59,7 @@ static int __cdns3_host_init(struct cdns3 *cdns) goto err1; } - if (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW) + if (cdns->pdata && (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW)) cdns->xhci_plat_data->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; ret = platform_device_add_data(xhci, cdns->xhci_plat_data, -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki