Received: by 10.223.164.202 with SMTP id h10csp4184526wrb; Mon, 20 Nov 2017 11:14:28 -0800 (PST) X-Google-Smtp-Source: AGs4zMZeYyfnO0davoj4+lC+22KY5wJtz8bt9PT3fn+UAN9I7CtUE+4zPW/T3RfSo66+HKipTD9O X-Received: by 10.84.192.131 with SMTP id c3mr15116088pld.435.1511205268541; Mon, 20 Nov 2017 11:14:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511205268; cv=none; d=google.com; s=arc-20160816; b=IL//s2Bxymld9Ft7bmux4BuJbAaAlXSlRg4bcSK+kyicjgusH7P0NxLKCzNyohZvkR Jdep2dZk9PCrxcjaemEnlIhTyMPDBGduSL0pVV3xdsO28MWnk9AXZrXH1WeeIHCzEzV+ kGHNmL510QNraSHTMIA7QHMzFVzj96UZd4RfTkKlMMqNBpVq2QR6cHGUQS3nh8cVz0qT ftclK34UHkEhR80gJu7ZD06bu26MUnYot0FyxzP2yE5eLu3kx88ZVF/m2iYIxH68Ogxz 32xGc+WNL8PC+835kdrFl4iU3GeMpFm7o5rXROsxWWEE1svo0BjH7FQ34vEoa7Iy2/x4 11zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=2XhK27qYGNScsPFPXczj368a9mluU87xAZnKjRaUr1c=; b=KBa8+824rS8iyyI3Pp6njDuXNRRmBRCQD1Y1ro/+C7wIAJLFnBUWnrAkJNfP79Jj/y SF6dz/n9HtuSWO7uLwzkvLAudHmIK2ilJ2/JOkS1XaqkA72A8BKFHTeRPsI0EaeeqAR4 9OiGQGuG8qGvpGQwxAg0oWUGmkpX1/CzN13h2amPu4YY5HIKpJEBgIKCitSWIpNEnpHq AKiUM166cVnGtdfCffPLRPgO4aR1cBvowtGG4cfm/migUQx0w/421NfnnuIQN3mCvcLz wtVoAp7/OLsN61RoCTQoylbseFdm7/sOhYqnzszT1XVVcYtpQpLP3pVEaLvWSHHkoKRG IKfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=fahuVJmT; dkim=pass header.i=@codeaurora.org header.s=default header.b=kUxQ61QQ; 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 y81si9761245pfb.21.2017.11.20.11.14.18; Mon, 20 Nov 2017 11:14:28 -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=@codeaurora.org header.s=default header.b=fahuVJmT; dkim=pass header.i=@codeaurora.org header.s=default header.b=kUxQ61QQ; 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 S1752360AbdKTTMa (ORCPT + 67 others); Mon, 20 Nov 2017 14:12:30 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34324 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752298AbdKTTM2 (ORCPT ); Mon, 20 Nov 2017 14:12:28 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C7E846080C; Mon, 20 Nov 2017 19:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511205147; bh=YG5J+r2D0NZ0/xw4o/QrhGionQzlqO6mWxeFgK3+uRs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fahuVJmTp4KRc1bg9q/LTf6f/7WyAbrRXVubdUEBIz+9XS6KTDtOqoXEOBnuS1q26 9vncEtxqTqUepovMkK/cBCyvb5Qic9+v/OY66yC0rHDDeBYEsJPqXwQS+RVyojegRl v8n/4gE7O98o3Ll/89ahasGnOFm8Od//5TP5aoto= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2ECCA607E8; Mon, 20 Nov 2017 19:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511205140; bh=YG5J+r2D0NZ0/xw4o/QrhGionQzlqO6mWxeFgK3+uRs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kUxQ61QQxjKu4s5kXcLuL3vnUA53mHCkVk+GPn4bOUPN3ypUB1W1UzvjUP++QcvQi yL6lttStesUUOa+wAUX8A3RKVistIx0PUqVnjWE8eUyc7kR0wX+gaH7NjgewWLUoIz usefb9x4Oz4GQ5tYyZwzRqNuS2bWbts2Xzn3ld8k= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2ECCA607E8 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sboyd@codeaurora.org Date: Mon, 20 Nov 2017 11:12:19 -0800 From: Stephen Boyd To: Chunyan Zhang Cc: Michael Turquette , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Cai Li , Orson Zhai , Chunyan Zhang Subject: Re: [PATCH] clk: fix a panic error caused by accessing NULL pointer Message-ID: <20171120191219.GD18379@codeaurora.org> References: <20171120033816.28414-1-chunyan.zhang@spreadtrum.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171120033816.28414-1-chunyan.zhang@spreadtrum.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/20, Chunyan Zhang wrote: > 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 Fixes: tag? > --- > 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); > + } Is the problem that parent may be NULL and the tracepoint dereferences it? Perhaps we need to update the tracepoint code instead so that we always see that the tracepoint is called even if we don't actually touch the hardware. Something like the patch below instead. ---8<---- diff --git a/include/trace/events/clk.h b/include/trace/events/clk.h index 758607226bfd..5a85ea2090c4 100644 --- a/include/trace/events/clk.h +++ b/include/trace/events/clk.h @@ -139,7 +139,7 @@ DECLARE_EVENT_CLASS(clk_parent, TP_fast_assign( __assign_str(name, core->name); - __assign_str(pname, parent->name); + __assign_str(pname, parent ? parent->name : NULL); ), TP_printk("%s %s", __get_str(name), __get_str(pname)) -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project From 1584555218460383528@xxx Mon Nov 20 03:46:54 +0000 2017 X-GM-THRID: 1584555218460383528 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread