Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1427556AbdDWFzb (ORCPT ); Sun, 23 Apr 2017 01:55:31 -0400 Received: from m50-134.163.com ([123.125.50.134]:50981 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1427539AbdDWFza (ORCPT ); Sun, 23 Apr 2017 01:55:30 -0400 From: Pan Bian To: Felipe Balbi , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] usb: dwc3: keystone: check return value Date: Sun, 23 Apr 2017 13:55:13 +0800 Message-Id: <1492926913-17428-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DtGowADnYWDCQfxYOmrcAA--.185S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKw17uw18Zr18uFyrXrWDArb_yoWfWFgEkw 1xurZ2gryxCrWvqFWjy343ArW2gF18Zr18ZF4kKw4akrWUGw1xXrZ5XrWkCrW7Aay29F9r Cr45Zw4a9rZ3tjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUUPEf3UUUUU== X-Originating-IP: [123.118.194.153] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiQAXCclSISvJFCAAAsc Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 855 Lines: 27 Function devm_clk_get() returns an ERR_PTR when it fails. However, in function kdwc3_probe(), its return value is not checked, which may result in a bad memory access bug. This patch fixes the bug. Signed-off-by: Pan Bian --- drivers/usb/dwc3/dwc3-keystone.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c index 7266470..12ee23f 100644 --- a/drivers/usb/dwc3/dwc3-keystone.c +++ b/drivers/usb/dwc3/dwc3-keystone.c @@ -107,6 +107,10 @@ static int kdwc3_probe(struct platform_device *pdev) return PTR_ERR(kdwc->usbss); kdwc->clk = devm_clk_get(kdwc->dev, "usb"); + if (IS_ERR(kdwc->clk)) { + dev_err(kdwc->dev, "unable to get usb clock\n"); + return PTR_ERR(kdwc->clk); + } error = clk_prepare_enable(kdwc->clk); if (error < 0) { -- 1.9.1