Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp450368pxj; Thu, 20 May 2021 13:13:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxE7WUoNKo5QcApRUDZKOxQjP3xiDc2HAjDjB1fbhLPNfI5Axspd3nY4RxLdpotqaJR68j X-Received: by 2002:a05:6602:221a:: with SMTP id n26mr6946992ion.205.1621541626370; Thu, 20 May 2021 13:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621541626; cv=none; d=google.com; s=arc-20160816; b=UdU2L4AyArxP1HThReK/ojVq+/JJleVtlHA0ueGcG1PoXq6CBDULXP2efaNw1jHW0w ru6bgk+nAM1GTTqdbUF5uU/JQzUqFXao1OtwFhXKVU51/4TOrTX5UoRi+KSXZLG3QjW4 ZxsXBNY5vlgKgcJSYnOnMUCwUF7hqsrNXbzMtyJZBKZzNb9mJXN5ai6qHDeJOVFYmfMx 2ubLksDPt5wzvY7qNfCXUcv6e4nSKlOX2QQ2cRShxgPdlAGXXzof3tsOAP8hyvkwmhfb Dpw1tD20/rtZ050/GDtXhbY3du/BlV6rjhm40y71iCS/w+8QSZ7qYzUOGRnrm8fki8A2 VC8w== 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=KOionsYfj+pCOP+GmuYCCmA19vKEYEI7eWg0L8Z3AMc=; b=TV3RjTlCVF4B9q1eWDB/ggWDt6umDAK2sj8ekAss00UtaISsmsPDbD1ClW25ddUDBB 47DTEAtAb5upuXrVEJ6kpitgmjG1JnUXph7FL/7ChvHTQG+QrL8jVwImuEIYdSJcHYKx 0sfQc+Wt4R7ADtu691QDoKK1bb68bTnj6gXRlk06y8q1rjcRISfHaqyQGzLfCYLZBKyj 7hvMudXYslG+SiXi8iPYpbOgq+ydTANgif32w0qTOiq+4hMs/udAKn/06ORYFgviOBu8 3qDK33R+XMvasl1H9U1qol6zSgiN+uzv504pUjcXtigBQnayU1x+PjZg/B2NHjJG1CVM R55Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CvI7l72p; 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=pass (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 a11si3648543jat.23.2021.05.20.13.13.32; Thu, 20 May 2021 13:13:46 -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=@linuxfoundation.org header.s=korg header.b=CvI7l72p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233694AbhETKrG (ORCPT + 99 others); Thu, 20 May 2021 06:47:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:60378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237284AbhETKb3 (ORCPT ); Thu, 20 May 2021 06:31:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CA06A61C4D; Thu, 20 May 2021 09:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504323; bh=TuqiWQ4ROAsgjp1Mjiz3bp9joRa+82z8UOoZwQuYqEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CvI7l72puJliooP326dYyNNCcqpJAzsCQ37SzbkKMl8rzBRzbU6x6oRL0iR+EMJzg 5hUeiIErMLfou5AwOHL21jvePVL/MbQmDXgvsLPHb4iXobGOVZbHuIAdvaiyt4/XJd JoQ0Owg88EK+WFK6WCW/F1W/tdbAa8wO8Nm3r28k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Jason Gunthorpe , Sebastian Reichel , Sasha Levin Subject: [PATCH 4.14 193/323] HSI: core: fix resource leaks in hsi_add_client_from_dt() Date: Thu, 20 May 2021 11:21:25 +0200 Message-Id: <20210520092126.736441964@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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: Dan Carpenter [ Upstream commit 5c08b0f75575648032f309a6f58294453423ed93 ] If some of the allocations fail between the dev_set_name() and the device_register() then the name will not be freed. Fix this by moving dev_set_name() directly in front of the call to device_register(). Fixes: a2aa24734d9d ("HSI: Add common DT binding for HSI client devices") Signed-off-by: Dan Carpenter Reviewed-by: Jason Gunthorpe Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/hsi/hsi_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/hsi/hsi_core.c b/drivers/hsi/hsi_core.c index 9065efd21851..71895da63810 100644 --- a/drivers/hsi/hsi_core.c +++ b/drivers/hsi/hsi_core.c @@ -223,8 +223,6 @@ static void hsi_add_client_from_dt(struct hsi_port *port, if (err) goto err; - dev_set_name(&cl->device, "%s", name); - err = hsi_of_property_parse_mode(client, "hsi-mode", &mode); if (err) { err = hsi_of_property_parse_mode(client, "hsi-rx-mode", @@ -306,6 +304,7 @@ static void hsi_add_client_from_dt(struct hsi_port *port, cl->device.release = hsi_client_release; cl->device.of_node = client; + dev_set_name(&cl->device, "%s", name); if (device_register(&cl->device) < 0) { pr_err("hsi: failed to register client: %s\n", name); put_device(&cl->device); -- 2.30.2