From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2578C5B57D for ; Fri, 5 Jul 2019 08:10:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 934C7218BC for ; Fri, 5 Jul 2019 08:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727196AbfGEIKY (ORCPT ); Fri, 5 Jul 2019 04:10:24 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:42570 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725862AbfGEIKX (ORCPT ); Fri, 5 Jul 2019 04:10:23 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C8AD79C6AC02954968C4; Fri, 5 Jul 2019 16:10:20 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Fri, 5 Jul 2019 16:10:11 +0800 From: Wei Yongjun To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , "Pierre-Louis Bossart" , Ranjani Sridharan , Pan Xiuli CC: Wei Yongjun , , , Subject: [PATCH -next] ASoC: SOF: debug: fix possible memory leak in sof_dfsentry_write() Date: Fri, 5 Jul 2019 08:16:37 +0000 Message-ID: <20190705081637.157169-1-weiyongjun1@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'string' is malloced in sof_dfsentry_write() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Fixes: 091c12e1f50c ("ASoC: SOF: debug: add new debugfs entries for IPC flood test") Signed-off-by: Wei Yongjun --- sound/soc/sof/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c index 54bb53bfc81b..2388477a965e 100644 --- a/sound/soc/sof/debug.c +++ b/sound/soc/sof/debug.c @@ -162,7 +162,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer, else ret = kstrtoul(string, 0, &ipc_count); if (ret < 0) - return ret; + goto out; /* limit max duration/ipc count for flood test */ if (flood_duration_test) { @@ -191,7 +191,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer, "error: debugfs write failed to resume %d\n", ret); pm_runtime_put_noidle(sdev->dev); - return ret; + goto out; } /* flood test */