Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1117768ybh; Thu, 23 Jul 2020 00:23:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlKn/5iJ8+jAKc15JgYMhfuJRoHvyacgvH3591YxL8ofEqHywUqr6caNP9bntWAhK/j43v X-Received: by 2002:a05:6402:3048:: with SMTP id bu8mr3009627edb.367.1595489003842; Thu, 23 Jul 2020 00:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595489003; cv=none; d=google.com; s=arc-20160816; b=d4D201GhIQMhr6y1wgFiclIn9zzZ0SMKiwINbpp9xVux/wKE1hf+Hxlb4s9EL3sqg/ Kqwamu+mZuAdyW6CEX0mm0TERkQiAv0naNLOv2xVoDFFnTcCgxRwktsQEF90bwRYrQo3 fJR8cafLB8IAXtoR0FvLqvvbZDgokyGehXFDOUzpWucme7zbEgLNzvgykwPWVYXDJUpL /dCVcM/RcQfr06cv3vgrsb1vF2/CAQCYSkTIGwmMwnKp+tPtAmij9YvuZSVxEdntlEem q+F4Mgh9IyQruxbI6Y3riLKZewwZ9WxlIw75Xvm1qTEciiCeckFZsXzI/b+GWmE9J2eQ 9eSw== 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=LXVybNlkoQIwB2+6ygE3GJIfa2qAylV544xMB3Aukp4OEa7UAJTmb5BE8ajE5Diicn hbM1P8K/W1pofOOGpSpsp8PPZN86qcA6otrBFsEhcgQL+WzWV/TNM/DRvLLWs/xy3fSf qMEFyHHQD9LaoGHAGx4SGDZ9LKsBrwDABAqbyjMC2CzvsfLq4al57cS+R6qgStrvdpm7 D0NRDauqNKfPszPYZP8hUa9/tgLpcyG2vgSSDKZc4gxxyBxOfwcYupQfu66AN2VNjUzo CBd3atQgE9OR373jlaXeC2bzfKDX6K9LgHGTKan+IUvV62+ylvkMqZQ8t/MQwEwEIz8K rJNQ== 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 j18si1583767edp.389.2020.07.23.00.23.00; Thu, 23 Jul 2020 00:23:23 -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 S1726945AbgGWHV4 (ORCPT + 99 others); Thu, 23 Jul 2020 03:21:56 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8362 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725857AbgGWHV4 (ORCPT ); Thu, 23 Jul 2020 03:21:56 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 20E486018A340EF0D308; Thu, 23 Jul 2020 15:21:52 +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; Thu, 23 Jul 2020 15:21:42 +0800 From: Yang Shen To: , CC: , , Subject: [PATCH v3 01/10] crypto: hisilicon/qm - fix wrong release after using strsep Date: Thu, 23 Jul 2020 15:19:31 +0800 Message-ID: <1595488780-22085-2-git-send-email-shenyang39@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595488780-22085-1-git-send-email-shenyang39@huawei.com> References: <1595488780-22085-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