Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp346898pxa; Tue, 4 Aug 2020 07:07:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymqHivEHg5VhPa35KK5X+NrGw3BLoykLlxsS4PI74WzlwZqAwKAfqKOd56f0anLSduj8to X-Received: by 2002:a17:906:af0c:: with SMTP id lx12mr7607022ejb.228.1596550029500; Tue, 04 Aug 2020 07:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596550029; cv=none; d=google.com; s=arc-20160816; b=BPCOfKAmVVjis79c3fo0yxat+xcQ3HhgqRqJFibqZ8Hm8ov9Lc8zboclYeRDYn/Dkq TksdpO9O87zRM49rxAsbXXHHzMJtmbVxff0qd8Z+hNqSn8OAtsta4JbojPaOqki1YUFO DB6EEvaL1Dqp+sTEIFGfgINFKJM+xSE6IfVFFuWjsfPoEEcF/hsYGx2YFwbVoUOShVoA TPrBWpi4M4O3Qm24+zQClvC3o02oqa6af84ck29yTJqPMp01RzJ5nDXfEUtGoOevUQuy dVXHiMpaSI9s9gIzO9gVYVSf3d+eNrHzmp4YoS9HCM1bn/cKwhdSl5IG8auazBx9OFjI 82ag== 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=QgJRl31AqD2JV8j8Aag+SA0bHDZW8ORxPsPiRSTd+cc=; b=n6N/q89j/A9G7nr5Bp36r7P5cyr2H6rl1RDokD4MwV8Ax/jbn+StQ5B7q0KXXvIKTW 75ILPSZ+h+r6CCTpTD95fCwzL6RIa/P+t6yaDpecOBuQmtvH6ImcLmLo8qPF93wX2TQK PB4hbUpwSYS4aI8/vRsI8RGDh2iA6k7KQYanFYLLynkkrv2buy6HjM9d4qXgkHLjKdHe 6vsTVeKteR1RSOSgaFXPqD7mxuC8J98lBFlrJReCCgTOitWlivFPKPiMwAahY4CXXUdg GkHiXOE9dYFO9nhqjeZlRb3Biko6INhmK30EQ1bAE1o3sder+ly6LAmYqaMn90AHNmjw 9ADg== 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 t2si12073598eje.689.2020.08.04.07.06.44; Tue, 04 Aug 2020 07:07:09 -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 S1728977AbgHDOFY (ORCPT + 99 others); Tue, 4 Aug 2020 10:05:24 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:60918 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728257AbgHDOAs (ORCPT ); Tue, 4 Aug 2020 10:00:48 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B6AD29A2E8246624B350; Tue, 4 Aug 2020 22:00:38 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Tue, 4 Aug 2020 22:00:29 +0800 From: Yang Shen To: , CC: , , , Subject: [PATCH v4 01/10] crypto: hisilicon/qm - fix wrong release after using strsep Date: Tue, 4 Aug 2020 21:58:21 +0800 Message-ID: <1596549510-2373-2-git-send-email-shenyang39@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596549510-2373-1-git-send-email-shenyang39@huawei.com> References: <1596549510-2373-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 6527c53..ffb28cc 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -1420,16 +1420,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; } @@ -1459,7 +1460,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