Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1503296pxa; Sun, 16 Aug 2020 00:24:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjc02VWOtZMELP0sSWCaMR+Lzw3JtHy/8hKjCMrQqgMEArfVTnfqSEWb/5V5+AqgNLvZYv X-Received: by 2002:a50:af83:: with SMTP id h3mr9881625edd.139.1597562684247; Sun, 16 Aug 2020 00:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597562684; cv=none; d=google.com; s=arc-20160816; b=EV5qJbnynDcGmZUrqrA/bsncjBKVb2hFmkSPQpmMa/KBcJgKmwBudrD5xYDWI46Xmh 4nFYbXbcoqKFU+UAiJmQEaofixIQPdl5KfKSaeryo+S8PB3WCkKa1pQqJyWEI+MhT7Rk UT+HLOlLasijGm7uorwD2VW83B3rQAhZoq3qTbVyRo1+eTGqrNeHT1pkGmFWxZwFkjOm Z8C9Y8zUjfvFR8fpcnz9zA4+VmR98PkKaOnEQ1kND+fcQlPfuoh1TqiCUa2XECCIM9Rr fZSCgB9UiXZkYMySMw1aEXjN9BF1jRAciy40eBwG2EYU0MF8uA+5CLc04V7uYP+I5g3I e3mA== 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=kHhPqmg5GVP/bshr69QX6Rk4d9POkhhP+WfHdYteA6U=; b=w9YEbwmKcTCW/CBEyClSvb+8Nd5dMdYN9kaF1khUVOcdj86HAOu+YJLmi/HrTY93EV KrEziWn8U8kE8zyMyJCvRW3htXHS3AAmWXm7kSjyaUKl//R93ZW93aygHLytEyPZa4s3 HFI7ToYeGLa8gYWrZ/HpjTATU9fJwIbizPqTlxS7wO6cIIWGTjnFURD3+aaGRWMBRAg+ OcEpkOiFkPlLsBJP1pck3B3AFar3RElY8rlKT9TKEYRh9aV5WnB4oawWfSdRQDwLhDGO 9FV+uxPTkGIQstv+CnyYE6dgHpTqiCbW60rArqLJmF3VIBL34mLEsz5wWaCRYloaI7// ljfA== 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 z25si8510356eje.701.2020.08.16.00.24.21; Sun, 16 Aug 2020 00:24:44 -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 S1729494AbgHPBoT (ORCPT + 99 others); Sat, 15 Aug 2020 21:44:19 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:33846 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729404AbgHPBoS (ORCPT ); Sat, 15 Aug 2020 21:44:18 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E344B9E201535795670E; Sat, 15 Aug 2020 17:58:28 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Sat, 15 Aug 2020 17:58:23 +0800 From: Yang Shen To: , CC: , , , Subject: [PATCH v5 01/10] crypto: hisilicon/qm - fix wrong release after using strsep Date: Sat, 15 Aug 2020 17:56:08 +0800 Message-ID: <1597485377-2678-2-git-send-email-shenyang39@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1597485377-2678-1-git-send-email-shenyang39@huawei.com> References: <1597485377-2678-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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 6527c53..fb389c0 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; } -- 2.7.4