Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1122654rdb; Fri, 20 Oct 2023 09:01:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjtb3+3MgIhPOeF4OykCp3mK16rXFnz1qKfh+IIy6+wPZckIV7WKmpDiGyVX7utT4p6vj+ X-Received: by 2002:a05:6a20:1604:b0:140:6979:295d with SMTP id l4-20020a056a20160400b001406979295dmr2055048pzj.2.1697817714843; Fri, 20 Oct 2023 09:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697817714; cv=none; d=google.com; s=arc-20160816; b=zsfY4EK91SBPA3hb2kmncvSTw9064IjWhuWX83BN2OqwotPbJwf8xFr79DC+omqS1w yNT8oOJxLJ3IYI/oNGf/oh/qtVTGQdP+sgTNTWQyF1G6mA2jO8MtFRVyxpy01dTUgjXW VAbeVE24hwkhmu4lx6SGZATIeNX/DTjEGww6sYhI1LFdDNdWknMgC5y8wbRNuqpu1oHH 5E/4N/mOQ32CYwzGxlU91BVQWIC6E82NjFP4bYxMW4c1AnR46CDnoIuS10ya2e/NAje1 UYbxX6j+1r5YLQuTrm+PKnE6tPAJ7/i0N8rq9Mn3rzqzk3C5e3kufBxwiBWboRj00r5G 5tMw== 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:cc:to:from:dkim-signature; bh=NcvcHF6syyTnw+TlLVd2nH8ZMZCU48+hIK7XQq6iEm0=; fh=/HNfN5sKYyD5/+w5ZCzXtqPHTPJVT6T5Km4Tk6SXW3Q=; b=IjwOTEYq/dlgObDygcp/cAGZVqcO299vjRUMLyTEB0PzPpWi/AVKAI280cELEVKV1U KsjpUJNgbHHC9fHT68XurFj469aAtSEBMUfCKFeLElpRmLeqicf+xINDDyy6LxFZSBGI HiBu0tSGV2RDL7EeIoEFY7X1sj292ZtnoQRsJLsi0425GkRbHHTNztm8LOP8fH7uPLbg +dn5ES5MxWpD4+/ewWLz27lWBZH5s7JWBPL3vNSuQ0Z8IfivqyUpcd2AdZ+zSDXv4hRR yrm3yzt5s66PyNgjBvcTe3hShENN6hLKjZOL4cwkSJSHBop2TTwETPbxirIE/qbstwjj 3k4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VSit08nN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s26-20020a63925a000000b005aca47c4214si2113667pgn.897.2023.10.20.09.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 09:01:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VSit08nN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D891D8130CBF; Fri, 20 Oct 2023 09:01:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377878AbjJTQBo (ORCPT + 99 others); Fri, 20 Oct 2023 12:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377871AbjJTQBk (ORCPT ); Fri, 20 Oct 2023 12:01:40 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2094C124 for ; Fri, 20 Oct 2023 09:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697817651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=NcvcHF6syyTnw+TlLVd2nH8ZMZCU48+hIK7XQq6iEm0=; b=VSit08nNsXovdnumtAHWn93pDIK5n3IuS5QJEFgzATGDoz0qy8UT19R9Eov/R5O9JlRzs4 EuYpbVsUlpxU2KfTQ/kQAGwKTdLFGBhMVHNAuXjbBmsGE//EKcbAbexm4Bh3/pHp3qwRJP 4xgYzeTsfW0FNhBpMq1lEU2cSfY2BLQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-FYn6_4HoM46po6gwZ1h0Hg-1; Fri, 20 Oct 2023 12:00:45 -0400 X-MC-Unique: FYn6_4HoM46po6gwZ1h0Hg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C811F3C025C8; Fri, 20 Oct 2023 16:00:44 +0000 (UTC) Received: from kalibr.redhat.com (unknown [10.47.238.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D9B32026D4C; Fri, 20 Oct 2023 16:00:43 +0000 (UTC) From: Maurizio Lombardi To: gregkh@linuxfoundation.org Cc: rafael@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] driver core: class: remove boilerplate code Date: Fri, 20 Oct 2023 18:00:42 +0200 Message-Id: <20231020160042.759439-1-mlombard@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 09:01:52 -0700 (PDT) Jump to err_out to avoid duplicating the code. Signed-off-by: Maurizio Lombardi --- drivers/base/class.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/base/class.c b/drivers/base/class.c index 05d9df90f621..7e78aee0fd6c 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -193,10 +193,8 @@ int class_register(const struct class *cls) lockdep_register_key(key); __mutex_init(&cp->mutex, "subsys mutex", key); error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name); - if (error) { - kfree(cp); - return error; - } + if (error) + goto err_out; cp->subsys.kobj.kset = class_kset; cp->subsys.kobj.ktype = &class_ktype; -- 2.39.3