Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26C7DC433E4 for ; Mon, 13 Jul 2020 09:47:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3FFB206F0 for ; Mon, 13 Jul 2020 09:47:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qdoOcox5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3FFB206F0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NnfaMwLUtQ85b8x0OV8YcIQwTsLv0v2cCaPmnJFPZHc=; b=qdoOcox5ls9UEkrwgAedwlIyA uVN2Poy5PAvjhCGasMmCtNsUBhFw8AoLPXfaLCn3CIjhPVTjGxr/Jm54fWEDZCWCT/A0dUuNndcd9 k4Y7D7MAkW43PZha0pj81OMt54E0Fj1dHvZF0j56xd8y8v3jYybD7oKwslOfZBKazsYN0j8cMY8mx Gib5v9lpvFyE/u0RPIYpKzZrp4zleofh5G6mbP2xWgX0ELeGzeL+64eO9SIOjnr2GwQd/s1XNffof ivnsi72tJ2Z9Jknq+S0o8W70m70/2eDl1nTZ05XQp4Y0FYBa3aGVbmDVCWvwZi0m/+XvUmvG6ruJD UpChoW5uQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1juv2P-00025I-4n; Mon, 13 Jul 2020 09:46:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1juv2H-00022i-M6 for linux-arm-kernel@lists.infradead.org; Mon, 13 Jul 2020 09:46:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E1E3931B; Mon, 13 Jul 2020 02:46:08 -0700 (PDT) Received: from [10.57.62.178] (unknown [10.57.62.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F81B3F7D8; Mon, 13 Jul 2020 02:46:07 -0700 (PDT) Subject: Re: [PATCH 4/4] perf/smmuv3: fix crash when platdata not specified To: Ajay Kumar , linux-arm-kernel@lists.infradead.org, robh+dt@kernel.org, mark.rutland@arm.com, will@kernel.org References: <20200712163341.61410-1-ajaykumar.rs@samsung.com> <20200712163341.61410-5-ajaykumar.rs@samsung.com> From: Robin Murphy Message-ID: <54027eac-6d75-7da8-ebaa-fb554f40933c@arm.com> Date: Mon, 13 Jul 2020 10:46:06 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200712163341.61410-5-ajaykumar.rs@samsung.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200713_054609_842193_625292A8 X-CRM114-Status: GOOD ( 21.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shaik.ameer@samsung.com, nleeder@codeaurora.org, shameerali.kolothum.thodi@huawei.com, alim.akhtar@samsung.com, Jay Chen , joro@8bytes.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-07-12 17:33, Ajay Kumar wrote: > The arm_smmuv3_pmu driver assumes platform data is always > available and exposes a possible NULL pointer deferencing > at the below line. > > model = *(u32 *)dev_get_platdata(smmu_pmu->dev); > > This patch fixes the bug by adding a check prior to the > deferencing of the platform data pointer. > > Signed-off-by: Ajay Kumar > --- > drivers/perf/arm_smmuv3_pmu.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c > index 25feab718c20..f7a27ae2f8d8 100644 > --- a/drivers/perf/arm_smmuv3_pmu.c > +++ b/drivers/perf/arm_smmuv3_pmu.c > @@ -710,9 +710,10 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu) > > static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu) > { > - u32 model; > + u32 model = 0; > > - model = *(u32 *)dev_get_platdata(smmu_pmu->dev); > + if (dev_get_platdata(smmu_pmu->dev)) > + model = *(u32 *)dev_get_platdata(smmu_pmu->dev); As I commented on the other series, ideally this could be something like: if (dev->of_node) model = of_device_get_match_data(dev->of_node); else model = *(u32 *)dev_get_platdata(dev); /* from IORT */ (and lose the "acpi_" from the function name, obviously) Robin. > > switch (model) { > case IORT_SMMU_V3_PMCG_HISI_HIP08: > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel