From patchwork Mon Nov 20 03:38:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 10065925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F6CD60597 for ; Mon, 20 Nov 2017 03:45:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3080928EAC for ; Mon, 20 Nov 2017 03:45:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2529228EC5; Mon, 20 Nov 2017 03:45:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAF2B28EAC for ; Mon, 20 Nov 2017 03:45:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751106AbdKTDpb (ORCPT ); Sun, 19 Nov 2017 22:45:31 -0500 Received: from sci-ig2.spreadtrum.com ([222.66.158.135]:13628 "EHLO SHSQR01.spreadtrum.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751105AbdKTDpa (ORCPT ); Sun, 19 Nov 2017 22:45:30 -0500 Received: from ig2.spreadtrum.com (shmbx01.spreadtrum.com [10.0.1.203]) by SHSQR01.spreadtrum.com with ESMTP id vAK3hTJ2054940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 20 Nov 2017 11:43:29 +0800 (CST) (envelope-from Chunyan.Zhang@spreadtrum.com) Received: from SHCAS02.spreadtrum.com (10.0.1.202) by SHMBX01.spreadtrum.com (10.0.1.203) with Microsoft SMTP Server (TLS) id 15.0.847.32; Mon, 20 Nov 2017 11:43:37 +0800 Received: from localhost (10.0.73.143) by SHCAS02.spreadtrum.com (10.0.1.250) with Microsoft SMTP Server (TLS) id 15.0.847.32 via Frontend Transport; Mon, 20 Nov 2017 11:43:36 +0800 From: Chunyan Zhang To: Stephen Boyd , Michael Turquette CC: , , Cai Li , Orson Zhai , Chunyan Zhang Subject: [PATCH] clk: fix a panic error caused by accessing NULL pointer Date: Mon, 20 Nov 2017 11:38:16 +0800 Message-ID: <20171120033816.28414-1-chunyan.zhang@spreadtrum.com> X-Mailer: git-send-email 2.12.2 MIME-Version: 1.0 X-MAIL: SHSQR01.spreadtrum.com vAK3hTJ2054940 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Cai Li In some cases the clock parent would be set NULL when doing re-parent, it will cause a NULL pointer accessing if clk_set trace event is enabled, since the trace event function would not check the input parameter. Signed-off-by: Cai Li Signed-off-by: Chunyan Zhang --- drivers/clk/clk.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index c8d83ac..64efaf0 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1242,13 +1242,12 @@ static int __clk_set_parent(struct clk_core *core, struct clk_core *parent, old_parent = __clk_set_parent_before(core, parent); - trace_clk_set_parent(core, parent); - /* change clock input source */ - if (parent && core->ops->set_parent) + if (parent && core->ops->set_parent) { + trace_clk_set_parent(core, parent); ret = core->ops->set_parent(core->hw, p_index); - - trace_clk_set_parent_complete(core, parent); + trace_clk_set_parent_complete(core, parent); + } if (ret) { flags = clk_enable_lock();