Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3653207img; Mon, 25 Mar 2019 15:00:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsHb5kbU65C83AvbmgB4A/Rtzbl/mvJD7tmyvcuC2Og9ReJoBarDO3DNgXB8YSQ7e7b1bu X-Received: by 2002:a17:902:e85:: with SMTP id 5mr27699334plx.13.1553551201350; Mon, 25 Mar 2019 15:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553551201; cv=none; d=google.com; s=arc-20160816; b=lsOL3zXAl/ej9pEnPgNGaKW/ME/Hq59BiLoGWwxckrGLycHHGzCPPjjyEs1v8ppxVK PoDL4caTCRRCZo53mXPkyEC+NQCGFxfiUtmHuzP0rl2AjlooSHsFciop8Z3X9I+1sAqD H0MCttNv5dfWI7O26fIBhwU7UwxOiAJaT8FEPznxzxtatw8o/bHrGoOdINQDVUfQ0VbZ ssgoAN0loYLzHealC4NRBGIhoxogniNQwn17b0nGq78bDMVqE47Ibi9M76m/jxyHhOGa AxsCx6aUhaEAuoYiUqL03GHZKHKyRqGhDagDWsrBBxoKAsRjdvHw0wY0snrO7cjTNDBn pGjQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YI9qkEj+rFYM7umj5PClpdVyq1EfX3s4+H1JkPwxAtc=; b=vEgcmPzfeEI8mpmWuDJa20UMtiIacfg7pBJvIsKeVx4jCDhrp9WCopwmo7cEY0bNur oZCk9SdrWJA+xJxopyt8z4AaA0Z6DJSHVqfXhD12p5ZnGR7Rp2M0QH9xIeg7gDIFnNuu XZnGufXKeRoKzZT+CYwIvZsrpUrJ3c51mGFRoA4wD5QU5ddCxwFrTIXadTcW9rBqFk+4 Vak646AycD5uyVu+8L3TlPd880R8p/zkQE8btkK4UFosdxBdbNm+ucP6sGjoTHUH0x+7 bzlM32PuJb4gPjqzghTkXIgYC6igGug7KrseTNJjZ/zzM3ipOql0DImXmDndzDwsTyt5 Sgtg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u19si14540207pga.567.2019.03.25.14.59.46; Mon, 25 Mar 2019 15:00:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730519AbfCYV7C (ORCPT + 99 others); Mon, 25 Mar 2019 17:59:02 -0400 Received: from muru.com ([72.249.23.125]:42580 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbfCYV67 (ORCPT ); Mon, 25 Mar 2019 17:58:59 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id B04C58120; Mon, 25 Mar 2019 21:59:12 +0000 (UTC) From: Tony Lindgren To: linux-omap@vger.kernel.org Cc: Dave Gerlach , Faiz Abbas , Greg Kroah-Hartman , Keerthy , Nishanth Menon , Peter Ujfalusi , Roger Quadros , Suman Anna , Tero Kristo , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 01/14] bus: ti-sysc: Fix sysc_unprepare() when no clocks have been allocated Date: Mon, 25 Mar 2019 14:58:36 -0700 Message-Id: <20190325215849.13182-2-tony@atomide.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190325215849.13182-1-tony@atomide.com> References: <20190325215849.13182-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we return early before ddata->clocks have been allocated we will get a NULL pointer dereference in sysc_unprepare(). Let's fix this by returning early when no clocks are allocated. Fixes: 0eecc636e5a2 ("bus: ti-sysc: Add minimal TI sysc interconnect target driver") Signed-off-by: Tony Lindgren --- drivers/bus/ti-sysc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c --- a/drivers/bus/ti-sysc.c +++ b/drivers/bus/ti-sysc.c @@ -1331,6 +1331,9 @@ static void sysc_unprepare(struct sysc *ddata) { int i; + if (!ddata->clocks) + return; + for (i = 0; i < SYSC_MAX_CLOCKS; i++) { if (!IS_ERR_OR_NULL(ddata->clocks[i])) clk_unprepare(ddata->clocks[i]); -- 2.21.0