diff options
author | Sihang Chen <chensihang1@hisilicon.com> | 2020-08-15 17:56:08 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2020-08-21 14:47:50 +1000 |
commit | 7bbfacc1a89e173ec5ae681b581257db3cf5cc26 (patch) | |
tree | 2e9be98a008a2b6fc0fc6a89b8aaf7cc260d1f1c /drivers/crypto/hisilicon | |
parent | b1a5c9a620f2b1792e51ae3961b16943e4f874f2 (diff) | |
download | lwn-7bbfacc1a89e173ec5ae681b581257db3cf5cc26.tar.gz lwn-7bbfacc1a89e173ec5ae681b581257db3cf5cc26.zip |
crypto: hisilicon/qm - fix wrong release after using strsep
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@hisilicon.com>
Signed-off-by: Yang Shen <shenyang39@huawei.com>
Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/hisilicon')
-rw-r--r-- | drivers/crypto/hisilicon/qm.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 6527c53b073f..fb389c030c44 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -1420,17 +1420,18 @@ 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); - return -EINVAL; + ret = -EINVAL; + goto err_buffer_free; } if (!strcmp(presult, "sqc")) @@ -1459,7 +1460,8 @@ 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); +err_buffer_free: + kfree(s_tmp); return ret; } |