From patchwork Sat May 8 02:36:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 12245725 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 BC952C433B4 for ; Sat, 8 May 2021 02:39:24 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5404F61448 for ; Sat, 8 May 2021 02:39:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5404F61448 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=QQPa9tmVRsB83WWtqQZ+GW+wK7GB0dCs6WA58RrqRRc=; b=VovfIvd+vxik/tokNgg1pnDMiR CarWQp2SVHh4DTjijCt87K5WaDiqDLPNZYjiXhAH0KOVNW0DfaTFnL+dqWGSCNyqZN7MWbyr5YL7h kLKHN19ZtrcaH5NVbvgcgg0Cx+yoDXM3ZQr+PGB9UyDOVHtgazsqX8tvjFW4louzTqmWuEaGSfnGU IVQiG7oRKLKEKpUW70RRsjpIIPKmHyBcx9EEk9kI3Coxnjz0k5kusiVBP33B2b4FksJ8MulnON0MH wwBAQQOAy5Q8Xdf+iIyE9h0VSDCzVClsIKJNjH8MUlnM6TPHvAM6o0ikKM4iNmKwWPCGk7j+asTTJ 8F22wbyQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lfCpu-008ZbM-Dr; Sat, 08 May 2021 02:36:58 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lfCpn-008Zaf-7C for linux-arm-kernel@desiato.infradead.org; Sat, 08 May 2021 02:36:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=4WGn2q4m19VOMNzoDZIBbTcYF+pU0UU60k26sYLLfRc=; b=cJr/a1lIVNUNUg4/e6ipjfjq9P uH1Q82yiLKkK0wTUwKg6Sf+uFd5hJ4x0CpxcCGcIW2wADMqH7Dvi8xpz/WsxKZQhVAU4HTKVXRSFm ohmMwEnOMlkskxr1oEGoggIriPKjgIHj1+0I9oRNaqRopVMqhuXqZJikQCD6f5P2BYK3LYU25wI67 DXt6G1j07SPQioFrUtHxHZzMNXrVKbZS/AAN6mcnmlaL7QiaNjqqVbA8RefoYmatxWPYsSOGTfEng jBRhnFDZ/2t1GZP6jVWi/CIz9ZM7+T0zMWnH157lv5vcEQGcwSZw244z2cqV+nyEbNzRBVOAo2cdV XJcUo0jg==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lfCpi-007KKX-VK for linux-arm-kernel@lists.infradead.org; Sat, 08 May 2021 02:36:48 +0000 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FcWbc225bzkWt8; Sat, 8 May 2021 10:34:04 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.177.72) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Sat, 8 May 2021 10:36:33 +0800 From: Zhen Lei To: Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , Greg Kroah-Hartman , linux-stm32 , linux-arm-kernel , linux-kernel CC: Zhen Lei Subject: [PATCH 1/1] stm class: dummy_stm: Fix error return code in dummy_stm_init() Date: Sat, 8 May 2021 10:36:15 +0800 Message-ID: <20210508023615.1827-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.177.72] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210507_193647_196346_86554B45 X-CRM114-Status: GOOD ( 12.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Although 'ret' has been initialized to -ENOMEM, but it will be reassigned by the "ret = stm_register_device(...)" statement in the for loop. So that, the value of 'ret' is unknown when kasprintf() failed. Fixes: bcfdf8afdebe ("stm class: dummy_stm: Create multiple devices") Reported-by: Hulk Robot Signed-off-by: Zhen Lei --- drivers/hwtracing/stm/dummy_stm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/stm/dummy_stm.c b/drivers/hwtracing/stm/dummy_stm.c index 38528ffdc0b3..36d32e7afb35 100644 --- a/drivers/hwtracing/stm/dummy_stm.c +++ b/drivers/hwtracing/stm/dummy_stm.c @@ -68,7 +68,7 @@ static int dummy_stm_link(struct stm_data *data, unsigned int master, static int dummy_stm_init(void) { - int i, ret = -ENOMEM; + int i, ret; if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX) return -EINVAL; @@ -80,8 +80,10 @@ static int dummy_stm_init(void) for (i = 0; i < nr_dummies; i++) { dummy_stm[i].name = kasprintf(GFP_KERNEL, "dummy_stm.%d", i); - if (!dummy_stm[i].name) + if (!dummy_stm[i].name) { + ret = -ENOMEM; goto fail_unregister; + } dummy_stm[i].sw_start = master_min; dummy_stm[i].sw_end = master_max;