Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1254849imw; Tue, 5 Jul 2022 06:30:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sAyXaDwXLTXsDwWxAX0Z0z9qFlgxq5e2WbHiLiCF9taN6z/SZwOn2wrep6skQD0wy6kR3c X-Received: by 2002:a63:8049:0:b0:412:8f0e:2da6 with SMTP id j70-20020a638049000000b004128f0e2da6mr93589pgd.414.1657027832006; Tue, 05 Jul 2022 06:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027831; cv=none; d=google.com; s=arc-20160816; b=xtcwIOKUHpOhnZt1Iyiq9VcCbWYZIek+iJ7AmALXJEHkoZflDvzCmHTKp2ffqXRca7 oHLputbw4hNLGeV1/58jJMUgLtPUrtJHnHrikLP6IdrkzUXygHSqhj11kUiRaXD/Lp5A /l/TDQ5ms+P6q66LFN/2CtombQ3IVU1p+7zyl08Og15f2OX+QxRsvie5ZEOLxcMZQ4Bj GUqtj8S+80WpTU/DlMrcbrrysgmBZFTiqHHDIRRgE2CUu4IkaGr2VTw+CBwgX9Yv3Bkg oNZ6FiFFvPw38TPFoTLzikADjLjwgBu5+Uk1nnh593CfVrmKPjbRLg5tJvwLhHVQOrh4 TiNQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2RZsWZNlwtkpTi1AZ4HkVof4zT1nNYYTE9PIZO7cIcw=; b=RgBYxXgT9zFiVC2n0aqpIxwysQwoN8P5I2iDAI488dI9fdgfOS4tMXMB3GKsgIopOQ o/d6k9Ko3H5ErUuVsnE594pQTme5Ktca4QzM17rX3mNVZFtsZNHTht4VQpyc94Fsx61v Ou4ZAlwM75WbmcIfw287xs+BvsqSUKu4vw6e8HV+ayIro+DQkyX2mLRxF4IR/5pKzJbE z7iPu3fZ5NrU3K4xRogawAh58fW96krBlt0pQmcuTWaB4uvUW4QkquOTj8heKWr2Hlv2 0g+rhuWmDEe5H9CdBPg9DDwEEx785PyYGr4LWthXaPSY0OJl+xbo84cs3AACqFVB6AaC 0USg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VfWPiFH9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p7-20020a17090a868700b001ef86e417ecsi7698755pjn.182.2022.07.05.06.30.17; Tue, 05 Jul 2022 06:30:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VfWPiFH9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234022AbiGEMGW (ORCPT + 99 others); Tue, 5 Jul 2022 08:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233617AbiGEMDl (ORCPT ); Tue, 5 Jul 2022 08:03:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563F517E18; Tue, 5 Jul 2022 05:03:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E576E6184D; Tue, 5 Jul 2022 12:03:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00D65C341C7; Tue, 5 Jul 2022 12:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022618; bh=CQl6euab5xGbNlx53hUvYix1BiHS9rLNvUdVGXVQJ1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VfWPiFH96O337WbYn95GsQaRweIR1lrAr2TJhqWjH0DAT69ug881vQP/UGEPRI+fh dhVS+XrZrMzuJKcOzzjuL/jq45SLjIw53dqOjSBPQEPaYK+ZJ6ttOndgnyvXzx3BA8 NZhBo4BYnOhoQoNk0tqqJ3LigmoIp6eLyxZby5tE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , Guenter Roeck , Sasha Levin Subject: [PATCH 4.19 23/33] hwmon: (ibmaem) dont call platform_device_del() if platform_device_add() fails Date: Tue, 5 Jul 2022 13:58:15 +0200 Message-Id: <20220705115607.391872617@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115606.709817198@linuxfoundation.org> References: <20220705115606.709817198@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit d0e51022a025ca5350fafb8e413a6fe5d4baf833 ] If platform_device_add() fails, it no need to call platform_device_del(), split platform_device_unregister() into platform_device_del/put(), so platform_device_put() can be called separately. Fixes: 8808a793f052 ("ibmaem: new driver for power/energy/temp meters in IBM System X hardware") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20220701074153.4021556-1-yangyingliang@huawei.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/ibmaem.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/hwmon/ibmaem.c +++ b/drivers/hwmon/ibmaem.c @@ -563,7 +563,7 @@ static int aem_init_aem1_inst(struct aem res = platform_device_add(data->pdev); if (res) - goto ipmi_err; + goto dev_add_err; platform_set_drvdata(data->pdev, data); @@ -611,7 +611,9 @@ hwmon_reg_err: ipmi_destroy_user(data->ipmi.user); ipmi_err: platform_set_drvdata(data->pdev, NULL); - platform_device_unregister(data->pdev); + platform_device_del(data->pdev); +dev_add_err: + platform_device_put(data->pdev); dev_err: ida_simple_remove(&aem_ida, data->id); id_err: @@ -703,7 +705,7 @@ static int aem_init_aem2_inst(struct aem res = platform_device_add(data->pdev); if (res) - goto ipmi_err; + goto dev_add_err; platform_set_drvdata(data->pdev, data); @@ -751,7 +753,9 @@ hwmon_reg_err: ipmi_destroy_user(data->ipmi.user); ipmi_err: platform_set_drvdata(data->pdev, NULL); - platform_device_unregister(data->pdev); + platform_device_del(data->pdev); +dev_add_err: + platform_device_put(data->pdev); dev_err: ida_simple_remove(&aem_ida, data->id); id_err: