From: Junhao He <hejunhao3@huawei.com>
To: <suzuki.poulose@arm.com>, <james.clark@arm.com>
Cc: <coresight@lists.linaro.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>,
<jonathan.cameron@huawei.com>, <yangyicong@huawei.com>,
<prime.zeng@hisilicon.com>, <hejunhao3@huawei.com>
Subject: [PATCH v2 2/4] coresight: ultrasoc-smb: Config SMB buffer before register sink
Date: Sat, 21 Oct 2023 16:38:20 +0800 [thread overview]
Message-ID: <20231021083822.18239-3-hejunhao3@huawei.com> (raw)
In-Reply-To: <20231021083822.18239-1-hejunhao3@huawei.com>
The SMB dirver register the enable/disable sysfs interface in function
smb_register_sink(), however the buffer depends on the following
configuration to work well. So it'll be possible for user to access an
unreset one.
Move the config buffer operation to before register_sink().
Fixes: 06f5c2926aaa ("drivers/coresight: Add UltraSoc System Memory Buffer driver")
Signed-off-by: Junhao He <hejunhao3@huawei.com>
---
drivers/hwtracing/coresight/ultrasoc-smb.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/hwtracing/coresight/ultrasoc-smb.c b/drivers/hwtracing/coresight/ultrasoc-smb.c
index 0a0fe9fcc57f..c61450f74cb1 100644
--- a/drivers/hwtracing/coresight/ultrasoc-smb.c
+++ b/drivers/hwtracing/coresight/ultrasoc-smb.c
@@ -583,38 +583,31 @@ static int smb_probe(struct platform_device *pdev)
return ret;
}
+ ret = smb_config_inport(dev, true);
+ if (ret)
+ return ret;
+
+ platform_set_drvdata(pdev, drvdata);
spin_lock_init(&drvdata->spinlock);
drvdata->pid = -1;
ret = smb_register_sink(pdev, drvdata);
if (ret) {
+ smb_config_inport(&pdev->dev, false);
dev_err(dev, "Failed to register SMB sink\n");
return ret;
}
- ret = smb_config_inport(dev, true);
- if (ret) {
- smb_unregister_sink(drvdata);
- return ret;
- }
-
- platform_set_drvdata(pdev, drvdata);
-
return 0;
}
static int smb_remove(struct platform_device *pdev)
{
struct smb_drv_data *drvdata = platform_get_drvdata(pdev);
- int ret;
-
- ret = smb_config_inport(&pdev->dev, false);
- if (ret)
- return ret;
smb_unregister_sink(drvdata);
- return 0;
+ return smb_config_inport(&pdev->dev, false);
}
#ifdef CONFIG_ACPI
--
2.33.0
next prev parent reply other threads:[~2023-10-21 8:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 8:38 [PATCH v2 0/4] Fixed some issues and cleanup of ultrasoc-smb Junhao He
2023-10-21 8:38 ` [PATCH v2 1/4] coresight: ultrasoc-smb: Fix sleep while close preempt in enable_smb Junhao He
2023-10-21 8:38 ` Junhao He [this message]
2023-10-21 8:38 ` [PATCH v2 3/4] coresight: ultrasoc-smb: Fix uninitialized before use buf_hw_base Junhao He
2023-10-21 8:38 ` [PATCH v2 4/4] coresight: ultrasoc-smb: Use guards to cleanup Junhao He
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=20231021083822.18239-3-hejunhao3@huawei.com \
--to=hejunhao3@huawei.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=prime.zeng@hisilicon.com \
--cc=suzuki.poulose@arm.com \
--cc=yangyicong@huawei.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: 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
all inboxes | Powered by JetHome®