Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp229753pxx; Wed, 28 Oct 2020 03:30:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOjDf7MYGl1ZfUzH6uR7KzQP8NjA/njnaw4vASdR8CTkNmZ8sd6HxeoHPG+41QvZgBNQzN X-Received: by 2002:a17:906:7096:: with SMTP id b22mr7180214ejk.335.1603881010518; Wed, 28 Oct 2020 03:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603881010; cv=none; d=google.com; s=arc-20160816; b=SFQsFTVII+FQ3ENcn3RjYR9WR3VRLFH+ibNG333K6bx9g0D151zCNurtRyDCfCN9fP N/9bW+DthwQKzj11xGEjBn2Cvwmq7liVyFvjOexkYhegg6S8xwuez79bj4GjmLE36F7I GrsPVSXvyytNF9gI8bHm1H2417jRsf7qDz9rWxCQE6dvIg9xj1M5emjZhuLUQAYVUzNI Nx3CS2HqgNOUOrrAD5GvW4jSKakkPhoYx5tCRna2ijR/UxPkRAf0l+pCH9V2F7nUKHUR 36NcDU28UT0o4YDWDHNNcVzHW6TV1oJIvjAu0DoCLrElGp0aRw7QVQ7sjTumBVAEED32 rNhQ== 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=oNyoyrDchAJH6NDO892Hyl9LkQ3iTKR2Uh6gS++jQCc=; b=ZjQnfn3xFF96n7oeza2eblDUXsAJ/gHQTdGXOHerbfKroA8nLv9w6ow9wDnqObSuYj yaxv/mdkwVGb1v9BlDeF2CLypuro2KQdhepRQH13AI1dQPyy7BHQvZ6XKrr2WoxRfDmn VDdiGw+DSOcIX3uK8x19mmzF9XpW2/WEGWzZQc1llFEgU/BMl8ZF6WTgtIeN0L8vNT2m 2xXQvr8JQp3H96rj6ohFIyQuElkud95YQ6LX8I628yVCsCodlPaKJ9tgpPsLUvGggJzD 6HzU2csMryEKVfdTH70AHNXSP4iABu2Ab8mM3lWx8AIM76kZlZX+Eo/2LRpnbK5KTqJm RiFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LSvLQue7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a42si3838927edf.535.2020.10.28.03.29.49; Wed, 28 Oct 2020 03:30:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LSvLQue7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762346AbgJ0OmQ (ORCPT + 99 others); Tue, 27 Oct 2020 10:42:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:39392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761704AbgJ0OkN (ORCPT ); Tue, 27 Oct 2020 10:40:13 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BDA8521D7B; Tue, 27 Oct 2020 14:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809611; bh=OS15gmOsKeMrUONXWqifnlsdksVi+vIPiTahFTwCgsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LSvLQue71Hct0S0zswOz9RU0/MMu+pTEKAdKu2hLr5Jnw9zrInstgXz7b1gq8wljh nAhJs+sHud7PDwuUXbFnBPan+UO/9YxoGvqinMvAV51dPpHFOBPe460DMT5Numh3w0 tPJ2aH2yNVBvBuo/KUN/oh8lleUJEtvXsoWWXzVw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jing Xiangfeng , Andrew Morton , Dan Carpenter , Matt Porter , Alexandre Bounine , "Gustavo A. R. Silva" , John Hubbard , Kees Cook , Madhuparna Bhowmik , Linus Torvalds , Sasha Levin Subject: [PATCH 5.4 258/408] rapidio: fix the missed put_device() for rio_mport_add_riodev Date: Tue, 27 Oct 2020 14:53:16 +0100 Message-Id: <20201027135507.008945453@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jing Xiangfeng [ Upstream commit 85094c05eeb47d195a74a25366a2db066f1c9d47 ] rio_mport_add_riodev() misses to call put_device() when the device already exists. Add the missed function call to fix it. Fixes: e8de370188d0 ("rapidio: add mport char device driver") Signed-off-by: Jing Xiangfeng Signed-off-by: Andrew Morton Reviewed-by: Dan Carpenter Cc: Matt Porter Cc: Alexandre Bounine Cc: Gustavo A. R. Silva Cc: John Hubbard Cc: Kees Cook Cc: Madhuparna Bhowmik Link: https://lkml.kernel.org/r/20200922072525.42330-1-jingxiangfeng@huawei.com Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- drivers/rapidio/devices/rio_mport_cdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c index 1222522b4ae76..2b08fdeb87c18 100644 --- a/drivers/rapidio/devices/rio_mport_cdev.c +++ b/drivers/rapidio/devices/rio_mport_cdev.c @@ -1683,6 +1683,7 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv, struct rio_dev *rdev; struct rio_switch *rswitch = NULL; struct rio_mport *mport; + struct device *dev; size_t size; u32 rval; u32 swpinfo = 0; @@ -1697,8 +1698,10 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv, rmcd_debug(RDEV, "name:%s ct:0x%x did:0x%x hc:0x%x", dev_info.name, dev_info.comptag, dev_info.destid, dev_info.hopcount); - if (bus_find_device_by_name(&rio_bus_type, NULL, dev_info.name)) { + dev = bus_find_device_by_name(&rio_bus_type, NULL, dev_info.name); + if (dev) { rmcd_debug(RDEV, "device %s already exists", dev_info.name); + put_device(dev); return -EEXIST; } -- 2.25.1