Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9929327ybi; Wed, 24 Jul 2019 12:30:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqBPcLGOVHx01Aho6+L6xot+xiQ+5bWlD01wsdhvhGBfAacnfNwzWYOasgSW6z9/leNige X-Received: by 2002:a62:764d:: with SMTP id r74mr13412800pfc.110.1563996650350; Wed, 24 Jul 2019 12:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996650; cv=none; d=google.com; s=arc-20160816; b=AGWp7stdaoyBhF6kJidLmDrYWnyWdv4Q/AnL95JLfw+LNQl2kDH4MPybxveQDph14T PZy7mCBUgZhWGQwJXwkrVYoCFImxU6uWUfQdGr7uAGq5/XbJ33Q3zjJUdHSg4DUoMbSj 2eM7LOKl1l6nzC4yS5HtiAFq/Da9Hx/FZYcPhZapQLtP89dA3DTjnE9v1heDSygh5mFW kCEBfCsApr3eSJO2FvAuK+FuTrqPDrHNhKsKqfKu88kJP6sybsuhH8m5WwK5GV7oYntw kudxXgRye5E5SXP2KDlhBvGDDoQFsQpY2cpaSVzpve0epP2JckQ9cP4etrPUohxmBuXJ d8DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M0WF6MA3IYPRdmRKPJcwr6VQTT6Dxr0oMiVKyi8yZZw=; b=h3kuTVbihXcA6G0fSl+XPihV37roP0YWYNYT9dyMIPOYpZRXkT68ygsxVolFBr5dSx 9eHQS7SXEvkr2k0oUMZz1NDwa2TQqy5JiRKLcnzEFjRrOdzA9DGcNm0NAslZPwhER2VJ Qsz2lLfoHWtFXbN6kJHko/SSUnokCZ2vJNqepFzT4o0aUNTDukwszMKeF59qYbVI/EUk nfxtn1Tp1FNVxEaK4OfEaklH46pz1OgaiTkZ1M7W1G2lwlAg+D/E3mfeooHDRpwUpftx to+Miee01MsPbE/FS5HWcCYG8841AmmG0WJZrV++RO4jZktP4mvBeM/54VnQ+2GNerWw 9hxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ng9XNKvM; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si15296291pgc.144.2019.07.24.12.30.35; Wed, 24 Jul 2019 12:30:50 -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=@kernel.org header.s=default header.b=ng9XNKvM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729000AbfGXT2v (ORCPT + 99 others); Wed, 24 Jul 2019 15:28:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:47420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728886AbfGXT2t (ORCPT ); Wed, 24 Jul 2019 15:28:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E186F21951; Wed, 24 Jul 2019 19:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996528; bh=S2yVBSm7lPNPpaNzZD2l8y2LHg6bt6MXEaEhLxtaK6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ng9XNKvMyXMH2Uq5glv8CBqvz8L03FrYLbVnffSPIlShwtws4JsvP87hfnLzWOHZO Yw4anL0ak+3WA6VgNohma8dmsa3/4hkgF+yUu5P2Ngh2xuLrcF0uzA8dJD94gsx/6D BdT+bskqPfUV3onpTbeBS0SuMqE89+S2m41P8pwE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Sasha Levin Subject: [PATCH 5.2 129/413] EDAC/sysfs: Drop device references properly Date: Wed, 24 Jul 2019 21:17:00 +0200 Message-Id: <20190724191744.308716730@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 7adc05d2dc3af95e4e1534841d58f736262142cd ] Do put_device() if device_add() fails. [ bp: do device_del() for the successfully created devices in edac_create_csrow_objects(), on the unwind path. ] Signed-off-by: Greg KH Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20190427214925.GE16338@kroah.com Signed-off-by: Sasha Levin --- drivers/edac/edac_mc_sysfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 464174685589..bf9273437e3f 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -443,7 +443,8 @@ static int edac_create_csrow_objects(struct mem_ctl_info *mci) csrow = mci->csrows[i]; if (!nr_pages_per_csrow(csrow)) continue; - put_device(&mci->csrows[i]->dev); + + device_del(&mci->csrows[i]->dev); } return err; @@ -645,9 +646,11 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci, dev_set_drvdata(&dimm->dev, dimm); pm_runtime_forbid(&mci->dev); - err = device_add(&dimm->dev); + err = device_add(&dimm->dev); + if (err) + put_device(&dimm->dev); - edac_dbg(0, "creating rank/dimm device %s\n", dev_name(&dimm->dev)); + edac_dbg(0, "created rank/dimm device %s\n", dev_name(&dimm->dev)); return err; } @@ -928,6 +931,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, err = device_add(&mci->dev); if (err < 0) { edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev)); + put_device(&mci->dev); goto out; } -- 2.20.1