From: Qi Liu <liuqi115@huawei.com> To: <mathieu.poirier@linaro.org>, <suzuki.poulose@arm.com>, <Al.Grant@arm.com> Cc: <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <linuxarm@huawei.com> Subject: [PATCH] coresight: Don't allocate pdata->conns when there is no output port Date: Tue, 8 Sep 2020 15:31:28 +0800 [thread overview] Message-ID: <1599550288-41724-1-git-send-email-liuqi115@huawei.com> (raw) When there is no output port, coresight_alloc_conns() still do the following copy connection information to pdata->conns, and this may cause kernel panic. Let's fix it. Signed-off-by: Qi Liu <liuqi115@huawei.com> --- drivers/hwtracing/coresight/coresight-platform.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index bfd4423..cdc8824 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -26,12 +26,13 @@ static int coresight_alloc_conns(struct device *dev, struct coresight_platform_data *pdata) { - if (pdata->nr_outport) { - pdata->conns = devm_kcalloc(dev, pdata->nr_outport, - sizeof(*pdata->conns), GFP_KERNEL); - if (!pdata->conns) - return -ENOMEM; - } + if (!pdata->nr_outport) + return -ENOMEM; + + pdata->conns = devm_kcalloc(dev, pdata->nr_outport, + sizeof(*pdata->conns), GFP_KERNEL); + if (!pdata->conns) + return -ENOMEM; return 0; } -- 2.8.1
WARNING: multiple messages have this Message-ID (diff)
From: Qi Liu <liuqi115@huawei.com> To: <mathieu.poirier@linaro.org>, <suzuki.poulose@arm.com>, <Al.Grant@arm.com> Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com Subject: [PATCH] coresight: Don't allocate pdata->conns when there is no output port Date: Tue, 8 Sep 2020 15:31:28 +0800 [thread overview] Message-ID: <1599550288-41724-1-git-send-email-liuqi115@huawei.com> (raw) When there is no output port, coresight_alloc_conns() still do the following copy connection information to pdata->conns, and this may cause kernel panic. Let's fix it. Signed-off-by: Qi Liu <liuqi115@huawei.com> --- drivers/hwtracing/coresight/coresight-platform.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index bfd4423..cdc8824 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -26,12 +26,13 @@ static int coresight_alloc_conns(struct device *dev, struct coresight_platform_data *pdata) { - if (pdata->nr_outport) { - pdata->conns = devm_kcalloc(dev, pdata->nr_outport, - sizeof(*pdata->conns), GFP_KERNEL); - if (!pdata->conns) - return -ENOMEM; - } + if (!pdata->nr_outport) + return -ENOMEM; + + pdata->conns = devm_kcalloc(dev, pdata->nr_outport, + sizeof(*pdata->conns), GFP_KERNEL); + if (!pdata->conns) + return -ENOMEM; return 0; } -- 2.8.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2020-09-08 7:32 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-08 7:31 Qi Liu [this message] 2020-09-08 7:31 ` [PATCH] coresight: Don't allocate pdata->conns when there is no output port Qi Liu 2020-09-11 17:59 ` Mathieu Poirier 2020-09-11 17:59 ` Mathieu Poirier
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=1599550288-41724-1-git-send-email-liuqi115@huawei.com \ --to=liuqi115@huawei.com \ --cc=Al.Grant@arm.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxarm@huawei.com \ --cc=mathieu.poirier@linaro.org \ --cc=suzuki.poulose@arm.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.