From: Robin Murphy <robin.murphy@arm.com>
To: Ajay Kumar <ajaykumar.rs@samsung.com>,
linux-arm-kernel@lists.infradead.org, robh+dt@kernel.org,
mark.rutland@arm.com, will@kernel.org
Cc: shaik.ameer@samsung.com, nleeder@codeaurora.org,
shameerali.kolothum.thodi@huawei.com, alim.akhtar@samsung.com,
Jay Chen <jkchen@linux.alibaba.com>,
joro@8bytes.org
Subject: Re: [PATCH 4/4] perf/smmuv3: fix crash when platdata not specified
Date: Mon, 13 Jul 2020 10:46:06 +0100 [thread overview]
Message-ID: <54027eac-6d75-7da8-ebaa-fb554f40933c@arm.com> (raw)
In-Reply-To: <20200712163341.61410-5-ajaykumar.rs@samsung.com>
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 <ajaykumar.rs@samsung.com>
> ---
> 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
next prev parent reply other threads:[~2020-07-13 9:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200712165509epcas5p29e66777a4e0115420b9104ba5aa83f57@epcas5p2.samsung.com>
2020-07-12 16:33 ` [PATCH 0/4] Add DT support for arm_smmuv3_pmu driver Ajay Kumar
2020-07-12 16:33 ` [PATCH 1/4] perf/smmuv3: Remove dependency on CONFIG_ACPI Ajay Kumar
2020-07-12 16:33 ` [PATCH 2/4] Documentation: perf: Add documentation for arm-smmu-v3-pmcg Ajay Kumar
2020-07-13 8:41 ` Jonathan Cameron
2020-07-12 16:33 ` [PATCH 3/4] perf/smmuv3: add device tree support Ajay Kumar
2020-07-12 16:33 ` [PATCH 4/4] perf/smmuv3: fix crash when platdata not specified Ajay Kumar
2020-07-13 8:46 ` Jonathan Cameron
2020-07-13 9:46 ` Robin Murphy [this message]
2020-07-13 9:42 ` [PATCH 0/4] Add DT support for arm_smmuv3_pmu driver Robin Murphy
2020-07-13 9:57 ` John Garry
2020-07-13 10:17 ` Ajay kumar
2020-07-13 10:28 ` Robin Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54027eac-6d75-7da8-ebaa-fb554f40933c@arm.com \
--to=robin.murphy@arm.com \
--cc=ajaykumar.rs@samsung.com \
--cc=alim.akhtar@samsung.com \
--cc=jkchen@linux.alibaba.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=nleeder@codeaurora.org \
--cc=robh+dt@kernel.org \
--cc=shaik.ameer@samsung.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).