Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1233970imw; Tue, 5 Jul 2022 06:11:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sQMAG8JixBZLCB5L/tYnkk2Md2r5Xh1LOwTF6OmRGyrTX043b/nGA+2nCm7MuxTlBHrKh6 X-Received: by 2002:a17:903:124c:b0:16b:a568:996d with SMTP id u12-20020a170903124c00b0016ba568996dmr33128992plh.169.1657026664398; Tue, 05 Jul 2022 06:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657026664; cv=none; d=google.com; s=arc-20160816; b=EptQnZpj9didb2aamgxJNjXJmDNx7OwEt+K3dJ99uLIp6B47vdjjKRQulSiZL3FrOL YURk/WpK0YeXFut1WJ+fDeOmzetIGaU49cK42ZJpFmFdTNYYWhCWL6AO4oPyRD9n5zkM g6M1d95rOIOYYoLvSnR32h6sGOEA2snUZLCC28OIrE1iX+VDCad2pak4gt+JFQE2FRRX MZHy3+lm2dLyQ6yrQ5gq1EEAT6PMbG6/ZuvQ2JZpIKkVDUTb3s9Dj9nDbhsGcEtNAS8F ndXfyfmpZJ0Tkp4b2YcolOnJ3v5Z/HnlFEoRogHS3v33p1XqYwjX0LKH+V3CPKEGxok9 Ph7w== 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=silkfjorQOS/CW7z5DtxYZjl8h1Xfd7GVtMfDOHXw/GhS3WPbdXKu9MfTwaIYQi3EF q0JZqaH+BWFuMBJ+a5RdNfmFGCh+72C1s5UCMXkZAM6SarlOCTl2NpkYajpwRji9tnzq h8fVDJF4QBXDpYo6wTAm8dHeU1M7LNJjStBMXSphenWwRIgOCeY7cBtQMjOE/lFoeAUn RCTEwdtIFjQrWUjsGrZYCml55eCCSadhRlpQ4lPFAa4bPwseXZ6sxBYet4QzuqBIy+VD L7egT2qIGLKuptOBO8pDJncmkbom5prRd0BMUXlP7m7ADiNlfsLcveFbCtqTNJf46msI +bGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="TUix//m/"; 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 a18-20020a17090a8c1200b001ef9c6822afsi1999163pjo.22.2022.07.05.06.10.53; Tue, 05 Jul 2022 06:11:04 -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="TUix//m/"; 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 S232633AbiGEL7s (ORCPT + 99 others); Tue, 5 Jul 2022 07:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232576AbiGEL7m (ORCPT ); Tue, 5 Jul 2022 07:59:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F13017AA4; Tue, 5 Jul 2022 04:59:41 -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 ams.source.kernel.org (Postfix) with ESMTPS id E004BB817DB; Tue, 5 Jul 2022 11:59:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B438C341CB; Tue, 5 Jul 2022 11:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022378; bh=CQl6euab5xGbNlx53hUvYix1BiHS9rLNvUdVGXVQJ1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUix//m/gDRrnnjV2IGYjMNC3ymutWZOB0H+1+l3cuMtdr33s4Ht10TbGlS0zQHKa De/5FR76ZNqEEgZbjRBwj5nAAgX32pSnLy+A/7OrgpR0Re86E5ywzmbdoSu91zrV0K 4ix7YvRprwTt4WXB39zSRvubE9SY4PDGA+daIg6M= 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.9 15/29] hwmon: (ibmaem) dont call platform_device_del() if platform_device_add() fails Date: Tue, 5 Jul 2022 13:57:56 +0200 Message-Id: <20220705115606.198393714@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115605.742248854@linuxfoundation.org> References: <20220705115605.742248854@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: