Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3062190ybt; Mon, 29 Jun 2020 14:16:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1HBMCG6buqK9XNImKGkuOppOvCRGhvh7Cu45hGnGYBmvp7uoPdB2v9i/4Ls2SBGn/ew5X X-Received: by 2002:aa7:d650:: with SMTP id v16mr19690135edr.361.1593465393687; Mon, 29 Jun 2020 14:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593465393; cv=none; d=google.com; s=arc-20160816; b=EpQLjAqizJfdx372iio64J7VbTWcyAnxR/JVGpkRvIV0vNlLxc13CTqzf1xHKEyTiX TM5RhIJVgm6ZypQiq6bKFGkxIgCG9jEhj1SVmNjJX25I/G3a/Sk7ryzeuGbS7JXOVaUm 77oXTXNg37LsIOz1Ly/OEc+9pVd6GDMiW5eUR7EkrcktOHtgfKpPAz7tYPj7O8kqg2xZ pDCG1ah0ZrHybjR1VsqLcFyI6VU0DRK6Q98T1PklJGROkeZlAEHJrDgTKtJxLzUkcJEZ tXclsSbZJ2YIlA3RaioNwB7c1UccHTMYZpY31hb2sJy+5qbQeYhYhXmDZzc8mcRvN2Ld Vy8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=kZnGfJjVH17HS8BI8C21QpPtvmTpjo5yL/Frm16d5A8=; b=OAym0BKIRAdVvjVRxFEqtJLqXd7G5R6JfE5V4F59b2X3LMyGsjeUx12OIGwiJQ9Z/w zpfAR3vrsYgqLLymbkZBhlJeHzjLd17NgS417tdqva7YNMy/IpxHiSws2UVYfAysm3Fd Z22k7Zp0IQc4OW/jvTpburTVmn6Y/2MgR5s3j9e9L2zO512VMY4RT8cqEsZhfPTdtAeh LdjtMQMMWdZic8dIfODf1zb9z1T1iCzURz90+VBHlldu5F6qB+f3tX0n/Nj4o69j+g/l Ra3RrgRJLbtvVGSo9S6L5esy3aEx1BZsuRR0c2Rea51VoXt5xJ9D1ZNpho+kPZP9FiJ7 gaig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si442824ejv.343.2020.06.29.14.16.10; Mon, 29 Jun 2020 14:16:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730076AbgF2VOs (ORCPT + 99 others); Mon, 29 Jun 2020 17:14:48 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59518 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730075AbgF2S5D (ORCPT ); Mon, 29 Jun 2020 14:57:03 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 36270B8D51D5EF15D635; Mon, 29 Jun 2020 19:10:58 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Mon, 29 Jun 2020 19:10:44 +0800 From: Yang Shen To: , CC: , , Subject: [PATCH 1/9] crypto: hisilicon/qm - fix wrong release after using strsep Date: Mon, 29 Jun 2020 19:09:00 +0800 Message-ID: <1593428948-64634-2-git-send-email-shenyang39@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593428948-64634-1-git-send-email-shenyang39@huawei.com> References: <1593428948-64634-1-git-send-email-shenyang39@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Sihang Chen 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 Signed-off-by: Shukun Tan --- 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