Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp382711ybt; Wed, 1 Jul 2020 00:27:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgBY7S+iXhrF+ANUe7VVtnTTbSg1oNEv4gVZyLXACaKMwXhz5veLzvIX5cRBhi2aW+dJ7A X-Received: by 2002:aa7:c816:: with SMTP id a22mr10380458edt.28.1593588454627; Wed, 01 Jul 2020 00:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593588454; cv=none; d=google.com; s=arc-20160816; b=AAJcJasAOjUGD0oU4zp6a9ur4GwaATqs7/8MsKLg+0ZUi4cNG9QEAFtIFMLpdhgJDP cjQdgZo1bMC0KN7DXgm29aAIHFfyH2+iyJfCytrCF1cjgWvX8tWDWihCW/R5QsDw0N2+ kNVjZ30fy3Jeatfe/PCyxP+ZEpYmNgmcFxKv2Fv4XThQ93IWRaH5kah4cyx1VLsG4u4t JNIbhMlIwLhJaFpU31MfOOWtJDB/ytSMHi45jofnIBgdWqCM9p1vpxc9Z8ysEOHQNlCM 9DfB5KwDuMR/J9Fg9Y6NxOoY1VZjT3OLat/mXubVNfbT6c8D+u587xpLCx8/7oQVSdRc Wrxg== 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=FwL2UlkgUog1ljNLQqRPhs8veIZFqgBklX1tVbGOORI=; b=qpGPjS6r8NOjUld7Z8R3AWFhpkN0zJHMMIyHy1QPf/mIn2zAPAs0kdiqWDH7OM4wrO 1t+GC/8z/12VgNJFuMNfsCTQBndxjGBRH+oyJg5cZ59d5ePP9IYS7riChZX5EzEoITNT YYzX83tAzneIABWk2AfXP9OlBXU4IAERMcYq9c2uSB8jC3RZ8j8F4tsS8hngyF6BAWDF BuDrdUx9EiyETr+1M7/F1pc2ZFLOvw1iAJjb5aBF/kR7GYIajDznD5zqyy56L5g5+KXn MPk8u2l4jSD0FCVQ3mL6d+P55gNBT4NA2ONo4wz0n9iEbaCY1rWnEdYY3MkGMD4ZtFYl VB9A== 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 h25si3482128edv.231.2020.07.01.00.27.11; Wed, 01 Jul 2020 00:27:34 -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 S1728055AbgGAHY1 (ORCPT + 99 others); Wed, 1 Jul 2020 03:24:27 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7324 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727847AbgGAHY0 (ORCPT ); Wed, 1 Jul 2020 03:24:26 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C688C7EA9D9637F5E05B; Wed, 1 Jul 2020 15:21:36 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Wed, 1 Jul 2020 15:21:30 +0800 From: Yang Shen To: , CC: , , Subject: [Patch v2 1/9] crypto: hisilicon/qm - fix wrong release after using strsep Date: Wed, 1 Jul 2020 15:19:47 +0800 Message-ID: <1593587995-7391-2-git-send-email-shenyang39@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593587995-7391-1-git-send-email-shenyang39@huawei.com> References: <1593587995-7391-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: Yang Shen Reviewed-by: Zhou Wang --- 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