From patchwork Wed May 29 08:44:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 165350 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp9581041ili; Wed, 29 May 2019 01:45:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8D8lsEqM/3UB4Yz1at+lbDmnuYIkHfFuw4BuvTxRRQOyq54TF9Ibn6aYPAzPjoKcsKGv3 X-Received: by 2002:a17:90a:cf18:: with SMTP id h24mr10591176pju.63.1559119555946; Wed, 29 May 2019 01:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559119555; cv=none; d=google.com; s=arc-20160816; b=w2VDSS6ZokT3Up8vgvm9vs1WRulussZoqZjP2PGsezssQ9dXdca7l6i8ETyJTiUf6c 8mOBR2IjVe0Zy5wfujoqQyzM2ks0LFmqX0G1HhnB4KGV8m18L5uw/+GVfvudxrWMY1Q3 s/0+N5NlnSdptMX1+L2r58ufUIQY42drMWoQRnT795eZPSC8Iiv2UbtjvyMawT+vH+a7 l7y+ZVxPAZiasnR3OBN1Mm4eG3SoXvEqjmKTnlplynlV4AlPzHLIEpFPTjtg7K5BR0Mn uVVZ25vCR/ONUEqebFTAmZ9deey3rUM3OM7WXLV7NPkyu85BCVk5Zz5cMLMpmXh3Just 0twQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-signature; bh=lQoZq7loVV5pKhsOJFBMbaakQmiE1B08uig6ldsAt6M=; b=mhJRu8OMLhYLEmwda/IrNx5kEvoG9P1FWWw4zuc4P/Okzp1KGos2nRVY+5nhBcaf2W NSLzLzxMlJOY4HwXsQHGRTOTG473wBboMaGSfx/5ho3Cr21tKAKbc1jMTlQaUGX/ddBi k8YF0BTaEEf+XhbIvIn1Q+Xe1CiUt2IVSosyFyjoh55aM+JvsU+cCeBggRt4uiQPq4in 05s7I1CWz3jeyMNbpWkgCJXqdkLhVVfFBqXgsN8b9ZYGhMnPEa4bGW7ZlHxFp0igE7Xp dQ49daMnhddQVAtRXNkMxM84mlnlUcjr0Qc9NRw8LhWs806iK1iRPmzkWBviMYvjPZj/ g7FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b="qFaeIO0/"; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=nYyzid2i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=marvell.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1si26711438pgj.147.2019.05.29.01.45.55; Wed, 29 May 2019 01:45:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b="qFaeIO0/"; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=nYyzid2i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726205AbfE2Ipy (ORCPT + 30 others); Wed, 29 May 2019 04:45:54 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:35312 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725888AbfE2Io0 (ORCPT ); Wed, 29 May 2019 04:44:26 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4T8eGJr022570; Wed, 29 May 2019 01:44:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=lQoZq7loVV5pKhsOJFBMbaakQmiE1B08uig6ldsAt6M=; b=qFaeIO0/2YcH4AQe77VJHrIjl8IMjqz42/5m3lO7w76a4M4h1cXcvo8JCd1HNM7WXYE9 8E8317C6LOlk+HLBjmfHnsUkyNahNOd0O82sgPqXgyy4ZZRcM6tGZP5/pBndLxestw8i 3ZwruiQrTf9BkHxGPAcA2lCsSG/lIPZSDCOL3gfe/P6CCyTZSzp81BLUtFTOhufJPMLc XQdsLbXxCde+vY94C/KQvKp/0vkiLIi3jb5LDs3NAIfKKyC30MfI7AFTcm8iQHQ5vz5O qDenoHAOGVuo5QNigh8vVyPXm59G1uyaW1eiObuvXUUHYk04+LaoQddFV8GryfuTYx5D Yg== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2sspkpg1ns-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 29 May 2019 01:44:09 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 29 May 2019 01:44:08 -0700 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (104.47.40.53) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 29 May 2019 01:44:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lQoZq7loVV5pKhsOJFBMbaakQmiE1B08uig6ldsAt6M=; b=nYyzid2i8u/dH7Mba8PO+2esypbKTHo8SyeYs4hsvT+GSbWdo+dsZHYb4PPo8vjOBUsbR+joz2G0U0I7UypXYscJ3jExMyXqVNqCL1e/0c6EnHScUrRKxrWvLlJqixtU9pKgEP+wZoNDi0Mdo6Xox0iWSok4MELer5rgMTsVA1k= Received: from MN2PR18MB3408.namprd18.prod.outlook.com (10.255.238.217) by MN2PR18MB3437.namprd18.prod.outlook.com (10.255.239.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.20; Wed, 29 May 2019 08:44:05 +0000 Received: from MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::7c9a:f3bf:fe2e:fe4a]) by MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::7c9a:f3bf:fe2e:fe4a%4]) with mapi id 15.20.1922.021; Wed, 29 May 2019 08:44:05 +0000 From: Robert Richter To: Borislav Petkov , Tony Luck , "James Morse" , Mauro Carvalho Chehab CC: "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Robert Richter Subject: [PATCH 02/21] EDAC: Fixes to use put_device() after device_add() errors Thread-Topic: [PATCH 02/21] EDAC: Fixes to use put_device() after device_add() errors Thread-Index: AQHVFfqscON641zZekePQqJCvaQr+Q== Date: Wed, 29 May 2019 08:44:05 +0000 Message-ID: <20190529084344.28562-3-rrichter@marvell.com> References: <20190529084344.28562-1-rrichter@marvell.com> In-Reply-To: <20190529084344.28562-1-rrichter@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR01CA0046.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::23) To MN2PR18MB3408.namprd18.prod.outlook.com (2603:10b6:208:16c::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [78.54.13.57] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ff4239af-1494-4fd7-a0a2-08d6e411ceda x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB3437; x-ms-traffictypediagnostic: MN2PR18MB3437: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:78; x-forefront-prvs: 0052308DC6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(396003)(376002)(39860400002)(136003)(189003)(199004)(8936002)(4326008)(53936002)(50226002)(110136005)(107886003)(68736007)(36756003)(5660300002)(54906003)(11346002)(26005)(186003)(52116002)(2906002)(2616005)(476003)(446003)(6506007)(14454004)(66476007)(25786009)(478600001)(386003)(86362001)(486006)(81166006)(81156014)(8676002)(305945005)(316002)(7736002)(14444005)(256004)(99286004)(76176011)(6512007)(6436002)(73956011)(64756008)(66446008)(66556008)(66066001)(3846002)(66946007)(1076003)(6486002)(102836004)(71190400001)(71200400001)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3437; H:MN2PR18MB3408.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: bQRXuxXA9tqwgHThqmWOYDPJiRxEPf7MYMootEWS/hFcgnw8btZg1ow57taOHsiEY2AYKgZyToEz39kiAXGOZOfiGvFF9fiZuHdglX1dIswwZKNuG+0I/2lIY/UgZEpPaqrFOKL7c0wNvd5ryBhE0DJtZAxHmKubSqNcg3jgmlybB+QkpceXlHpWVSCKxzVbJKLl83t9q5T8rhWN4SE4ghc1y1I78KdqsvIC5uEKiFk7AU6v80ygOTJOvNv0IJth7TOFjl1fjHoSo1WXtjQCX6eTeJ4Uwxd8Z95LWGQwijpzGD69k8dhK9cMuz5HbemEdaON8Qn2bBEtS18Cq0OH69CeRgliUdtbFZSWbUeLEpfUuhbEYv+B58jZ6WirUJHRsLV7yUJpt7WqXRm1PkjfnptQOs9+A6uiOx/b8PvFKW0= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: ff4239af-1494-4fd7-a0a2-08d6e411ceda X-MS-Exchange-CrossTenant-originalarrivaltime: 29 May 2019 08:44:05.8207 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rrichter@marvell.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3437 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-29_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Always use put_device() after device_add() failed. Signed-off-by: Robert Richter --- drivers/edac/edac_mc_sysfs.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) -- 2.20.1 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 464174685589..dbef699162a8 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -404,6 +404,8 @@ static inline int nr_pages_per_csrow(struct csrow_info *csrow) static int edac_create_csrow_object(struct mem_ctl_info *mci, struct csrow_info *csrow, int index) { + int err; + csrow->dev.type = &csrow_attr_type; csrow->dev.groups = csrow_dev_groups; device_initialize(&csrow->dev); @@ -415,7 +417,11 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci, edac_dbg(0, "creating (virtual) csrow node %s\n", dev_name(&csrow->dev)); - return device_add(&csrow->dev); + err = device_add(&csrow->dev); + if (err) + put_device(&csrow->dev); + + return err; } /* Create a CSROW object under specifed edac_mc_device */ @@ -646,8 +652,11 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci, pm_runtime_forbid(&mci->dev); err = device_add(&dimm->dev); - - edac_dbg(0, "creating rank/dimm device %s\n", dev_name(&dimm->dev)); + if (err) + put_device(&dimm->dev); + else + edac_dbg(0, "creating rank/dimm device %s\n", + dev_name(&dimm->dev)); return err; } @@ -927,8 +936,9 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, edac_dbg(0, "creating device %s\n", dev_name(&mci->dev)); err = device_add(&mci->dev); if (err < 0) { + put_device(&mci->dev); edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev)); - goto out; + return err; } /* @@ -977,7 +987,6 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, } device_unregister(&mci->dev); -out: return err; } @@ -1034,10 +1043,8 @@ int __init edac_mc_sysfs_init(void) int err; mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL); - if (!mci_pdev) { - err = -ENOMEM; - goto out; - } + if (!mci_pdev) + return -ENOMEM; mci_pdev->bus = edac_get_sysfs_subsys(); mci_pdev->type = &mc_attr_type; @@ -1046,15 +1053,10 @@ int __init edac_mc_sysfs_init(void) err = device_add(mci_pdev); if (err < 0) - goto out_put_device; - - edac_dbg(0, "device %s created\n", dev_name(mci_pdev)); - - return 0; + put_device(mci_pdev); + else + edac_dbg(0, "device %s created\n", dev_name(mci_pdev)); - out_put_device: - put_device(mci_pdev); - out: return err; }