Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp917690pxu; Mon, 23 Nov 2020 07:19:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAN0RUf6nWir7YafkyVpmZPYCLb8Y6ZGxdshS8DlV8J5DJMK7oaiqcbSOe823Xc+ZDO86D X-Received: by 2002:a17:906:a106:: with SMTP id t6mr82916ejy.63.1606144758347; Mon, 23 Nov 2020 07:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606144758; cv=none; d=google.com; s=arc-20160816; b=oQja92mAbcOt9dvoHsOJUMXLXECDDJ4CEuc1ucFvQGyZ24PKWXA+qGG+38PO6FLlpa grdCldn+RaiHNS9LcA4kY9Q+6MI+Nd05/GG0Ld31ZbIdmIZditaVotNCOXpi4Eodolih 3ALlcdJxu/RxT6TIYm9hWqis/PxO3GhIvtRvCiwY2FrmHKmXHMLl/20czE1v0v+K0AyI 7v50hxpzWQgdQE+MqaFl/fymEdyBtsfl2f6M05PE3Bae/HU770lOCPzDaacj0Vd3g2s1 91ArD28PEeEQYBgqJKajNOIcGur/qPMRfEr/zTEg647JsV86EygHw3tzZ6kaQC05eqfh U/LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=r3pZGqVUYurHf2eWbuhO4jAXjPaX5jQ0h5MgmBDdvCA=; b=eVuaJ0VGJhEeD1w/PGE8YMTNMrzz6iFeICsPRBgtBA/kl4h0P5P7bFp+L/gUzuMcNt ep0kIOXsTPFElACdYA+rYAuOPB9zvuhUwA3Og+Tvc+4QjPss57I50aoWkWDcAIeyJocz 1GGlxDbWalzcixXX4MNEqqQX1f3AvcpFTIPRdb214ZsrTCSb34K4Gne8QWO+Ql30N8CO rFDVCsGDy0tRDE9so25Xb8ODiSz1Y4QR7EXZaZ6j46MPNTE3FvKyu6J32idpD8Mcn3uz 9ir8zXBPQNR6BMt2fOABGLGl9tUKIt8QM9nVCZJAvd+GI6wXwxxS6lFmiXCulABSu1nc 6xfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 a3si6802852edq.430.2020.11.23.07.18.54; Mon, 23 Nov 2020 07:19:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731120AbgKWPOY (ORCPT + 99 others); Mon, 23 Nov 2020 10:14:24 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8018 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729718AbgKWPOX (ORCPT ); Mon, 23 Nov 2020 10:14:23 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CfrK46PY1zhgHQ; Mon, 23 Nov 2020 23:14:00 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Mon, 23 Nov 2020 23:14:14 +0800 From: Wang Hui To: , , , , , Subject: [PATCH] hwtracing: stm: fix return value of error branch in stm_heartbeat_init Date: Mon, 23 Nov 2020 15:14:38 +0000 Message-ID: <20201123151438.258314-1-john.wanghui@huawei.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ret would be reset by stm_source_register_device after first loop, so we should reassign ret while allocation failed for stm_heartbeat[i].data.name Reported-by: Hulk Robot Fixes: 119291853038 ("stm class: Add heartbeat stm source device") Signed-off-by: Wang Hui --- drivers/hwtracing/stm/heartbeat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/stm/heartbeat.c b/drivers/hwtracing/stm/heartbeat.c index 3e7df1c0477f..81d7b21d31ec 100644 --- a/drivers/hwtracing/stm/heartbeat.c +++ b/drivers/hwtracing/stm/heartbeat.c @@ -64,7 +64,7 @@ static void stm_heartbeat_unlink(struct stm_source_data *data) static int stm_heartbeat_init(void) { - int i, ret = -ENOMEM; + int i, ret; if (nr_devs < 0 || nr_devs > STM_HEARTBEAT_MAX) return -EINVAL; @@ -72,8 +72,10 @@ static int stm_heartbeat_init(void) for (i = 0; i < nr_devs; i++) { stm_heartbeat[i].data.name = kasprintf(GFP_KERNEL, "heartbeat.%d", i); - if (!stm_heartbeat[i].data.name) + if (!stm_heartbeat[i].data.name) { + ret = -ENOMEM; goto fail_unregister; + } stm_heartbeat[i].data.nr_chans = 1; stm_heartbeat[i].data.link = stm_heartbeat_link; -- 2.29.0