From nobody Fri Dec 19 21:15:15 2025 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73390155C83; Thu, 27 Feb 2025 04:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740629534; cv=none; b=qf3Ppux+SoWQsWJXpVeQ1b96eAp7n4Np+OaBwUofIsFzY/6L6Gy00xt5TR9YK34U3A9VMxqfmJmI5nxBUV7jSIoVJDmpVHWhJVp61RzZASiZc5Vyb7+OAKhkIhOKHmWqf9j/ocPUQ8USLKlS2tycflb2mAiOa/fqzZURZ+IqQAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740629534; c=relaxed/simple; bh=ybY/sARb+gPAvCAk6Va97MKMqDLi75HCr3W/1QuDbMs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=a6L+llLHhSCw4tuaN95/xi4Zr+/R2xtcEND/rwkO7fiOX0/NpcwKMsF5WYDnzyk8ZtBpBUdzi6KbCRWLqkFXU5rRgLUu2YWfEAlJhn3iSYMNVXBtXH45QP+13kM4xvbju8wGVjYfaWXVCSbxMKpLOCLu/qqnPy3M8hvyBNWN7NY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=FqBqiK88; arc=none smtp.client-ip=220.197.31.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="FqBqiK88" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=sbeia VhCJsLMybPrAPQBZ4W7ilebZ7V3fMGQzrDnTS0=; b=FqBqiK88aC2iOBfzZXzha ls4fwk3FySNvb1NIhUQ32CJS5s7um1ZQP0NzXBHnKoJOfSb+flhXp++99fMiXsT1 R/6vHN2KHzl/iL54tzRs1vH2HjWVn7eUR9ChelP4K1g87MJHchplXgp+ij5N94td tBqkoLSfDTmKzVvYOLlylo= Received: from icess-ProLiant-DL380-Gen10.. (unknown []) by gzga-smtp-mtada-g1-2 (Coremail) with SMTP id _____wD3r2_15b9no7HcOw--.42050S4; Thu, 27 Feb 2025 12:11:34 +0800 (CST) From: Haoxiang Li To: mporter@kernel.crashing.org, alex.bou9@gmail.com, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Haoxiang Li , stable@vger.kernel.org, Yang Yingliang Subject: [PATCH] rapidio: Add check for rio_add_net() in rio_scan_alloc_net() Date: Thu, 27 Feb 2025 12:11:31 +0800 Message-Id: <20250227041131.3680761-1-haoxiang_li2024@163.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wD3r2_15b9no7HcOw--.42050S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7GrW3ur18WrWUKF43ZFWkZwb_yoWDCrb_WF 4fWw4fXrZYkF4xtrn09r4avrWS9r48Xrs7uFWaq393JFW3ZwnYgry8urW5G3y7u3y8Crn3 Z3Wqgr18ur17ujkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRWGQhUUUUUU== X-CM-SenderInfo: xkdr5xpdqjszblsqjki6rwjhhfrp/1tbiqAQBbme-3Uf9WgAAsm Content-Type: text/plain; charset="utf-8" The return value of rio_add_net() should be checked. If it fails, put_device() should be called to free the memory and give up the reference initialized in rio_add_net(). Fixes: e6b585ca6e81 ("rapidio: move net allocation into core code") Cc: stable@vger.kernel.org Signed-off-by: Yang Yingliang Signed-off-by: Haoxiang Li --- drivers/rapidio/rio-scan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index fdcf742b2adb..b9daacc7f1ec 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c @@ -871,7 +871,10 @@ static struct rio_net *rio_scan_alloc_net(struct rio_m= port *mport, dev_set_name(&net->dev, "rnet_%d", net->id); net->dev.parent =3D &mport->dev; net->dev.release =3D rio_scan_release_dev; - rio_add_net(net); + if (rio_add_net(net)) { + put_device(&net->dev); + net =3D NULL; + } } =20 return net; --=20 2.25.1