From patchwork Fri Mar 19 14:46:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12151231 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=-14.0 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,UNPARSEABLE_RELAY, URIBL_BLOCKED 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 41D0FC433DB for ; Fri, 19 Mar 2021 14:48:52 +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 D8E3B64DC4 for ; Fri, 19 Mar 2021 14:48:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8E3B64DC4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.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:Subject:Cc:To:From:Date: 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=g5nptoc2HY9N/UNAfesUiLWTfqRJoDJGuvG/zdFFwxo=; b=j7ajp6yaPo3FuJ9lwyhE1u5043 y8Y+/tpZLzzrmPQena1p2sSb81Ii4Pg0v04uNVrKqXBCGTnRQmhTIJYUcARPLG4jEnp0kr5dth5M4 RKZqIqXhQvorAYsZoHd7bf0bNQo7glnPdXG3Ahq99KbJH4t/ibOhB+sSkrKmWXz1UmEScV730XhTi LyWMXFeocaBjEPFbGa4cUFQbml9IkWDKQxqhIz/1LMNuchniDxzwwPw8z7lISvR4J4PYe+Cs+1kR2 ujg9jmIMX8VT306MIIvM8w5QfMwmoWZstLLLypkLEQEZ/Omr1JzycALmsfxSlfHJMQWHh7O25pIm4 TdLBwgNg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNGPC-007Z28-NB; Fri, 19 Mar 2021 14:47:15 +0000 Received: from userp2120.oracle.com ([156.151.31.85]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNGP7-007Z1O-Cn for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 14:47:11 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12JEaOTx135621; Fri, 19 Mar 2021 14:46:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=XNO61FOtBVkhZAr4aIEkfaV06YebUAqWlN4HB4v3cPQ=; b=dSr4+HP/s7HaUjw6k9kW0TrCt73vSpsQqvNjPKKwVjvDNfY3m6TyLuHaLkNcYv+/viLo CXhpDuwnhg9HhSPT553+MULe9Dz9xtX+DH6xxnBAr0AHjXs4j07eSDuVZQaUK3kyddgD dr2m0/RTz/AyByniU1w99zpavm3GKNh4x0wm0DLet9GO/5rXI2oC6OaznlRdcqDnLprv /juzqmepU/8j/hTBrxawvN3OKA2c7Io38vPOiEOL9H+/fMAO9/JCzKrRlx82Q8CSHVth UQe9bfAINdCuVOvbIUqWJh8uqNFlQ+0J7klb2d73QMufkf6dkK47eDJBDHeVd5nB3EOZ nw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 378p1p376a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Mar 2021 14:46:55 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12JEa6hS137011; Fri, 19 Mar 2021 14:46:53 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 37cf2vj35h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Mar 2021 14:46:53 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 12JEklC5009955; Fri, 19 Mar 2021 14:46:51 GMT Received: from mwanda (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 19 Mar 2021 07:46:47 -0700 Date: Fri, 19 Mar 2021 17:46:37 +0300 From: Dan Carpenter To: Alexander Shishkin Cc: Maxime Coquelin , Alexandre Torgue , Greg Kroah-Hartman , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] stm: class: dummy_stm: fix an error code in dummy_stm_init() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-IMR: 1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9928 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103190106 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9928 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 adultscore=0 spamscore=0 clxscore=1011 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103190106 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_144709_795129_3FC580C8 X-CRM114-Status: GOOD ( 20.62 ) 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 If the kasprintf() allocation fails after the first iteration through the loop then it returns success instead of -ENOMEM as intended. Fixes: bcfdf8afdebe ("stm class: dummy_stm: Create multiple devices") Signed-off-by: Dan Carpenter --- 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;