From: Yang Shen <shenyang39@huawei.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>
Cc: <linux-crypto@vger.kernel.org>, <xuzaibo@huawei.com>,
<wangzhou1@hisilicon.com>
Subject: [PATCH 1/9] crypto: hisilicon/qm - fix wrong release after using strsep
Date: Mon, 29 Jun 2020 19:09:00 +0800 [thread overview]
Message-ID: <1593428948-64634-2-git-send-email-shenyang39@huawei.com> (raw)
In-Reply-To: <1593428948-64634-1-git-send-email-shenyang39@huawei.com>
From: Sihang Chen <chensihang1@hisilicon.com>
Save the string address before pass to strsep, release it at end.
Because strsep will update the string address to point after the
token.
Fixes: c31dc9fe165d("crypto: hisilicon/qm - add DebugFS for xQC and...")
Signed-off-by: Sihang Chen <chensihang1@huawei.com>
Signed-off-by: Shukun Tan <tanshukun1@huawei.com>
---
drivers/crypto/hisilicon/qm.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 9bb263c..ad0adcc 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -1429,16 +1429,17 @@ static int qm_dbg_help(struct hisi_qm *qm, char *s)
static int qm_cmd_write_dump(struct hisi_qm *qm, const char *cmd_buf)
{
struct device *dev = &qm->pdev->dev;
- char *presult, *s;
+ char *presult, *s, *s_tmp;
int ret;
s = kstrdup(cmd_buf, GFP_KERNEL);
if (!s)
return -ENOMEM;
+ s_tmp = s;
presult = strsep(&s, " ");
if (!presult) {
- kfree(s);
+ kfree(s_tmp);
return -EINVAL;
}
@@ -1468,7 +1469,7 @@ static int qm_cmd_write_dump(struct hisi_qm *qm, const char *cmd_buf)
if (ret)
dev_info(dev, "Please echo help\n");
- kfree(s);
+ kfree(s_tmp);
return ret;
}
--
2.7.4
next prev parent reply other threads:[~2020-06-29 21:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-29 11:08 [PATCH 0/9] crypto: hisilicon/qm - misc fixes Yang Shen
2020-06-29 11:09 ` Yang Shen [this message]
2020-07-01 7:01 ` [PATCH 1/9] crypto: hisilicon/qm - fix wrong release after using strsep shenyang (M)
2020-06-29 11:09 ` [PATCH 2/9] crypto: hisilicon/qm - clear used reference count when start qp Yang Shen
2020-06-29 11:09 ` [PATCH 3/9] crypto: hisilicon/qm - fix print frequence in hisi_qp_send Yang Shen
2020-06-29 11:09 ` [PATCH 4/9] crypto: hisilicon/qm - fix judgement of queue is full Yang Shen
2020-06-29 11:09 ` [PATCH 5/9] crypto: hisilicon/qm - fix event queue depth to 2048 Yang Shen
2020-06-29 11:09 ` [PATCH 6/9] crypto: hisilicon/qm - fix no stop reason when use hisi_qm_stop Yang Shen
2020-06-29 11:09 ` [PATCH 7/9] crypto: hisilicon/qm - fix VF not available after PF FLR Yang Shen
2020-06-29 11:09 ` [PATCH 8/9] crypto: hisilicon/qm - fix the process of register algorithms to crypto Yang Shen
2020-06-29 11:09 ` [PATCH 9/9] crypto: hisilicon/qm - register callback function to 'pci_driver.shutdown' Yang Shen
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=1593428948-64634-2-git-send-email-shenyang39@huawei.com \
--to=shenyang39@huawei.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=wangzhou1@hisilicon.com \
--cc=xuzaibo@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;
as well as URLs for NNTP newsgroup(s).