Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4617513pxj; Wed, 12 May 2021 09:20:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgU0Y4/WPtQMjz506D5yXtnIxmECFKg/RxThAH6X89yfma6ZPcsScYnOTUthajB8OqvBr9 X-Received: by 2002:a2e:a586:: with SMTP id m6mr3546268ljp.370.1620836405399; Wed, 12 May 2021 09:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836405; cv=none; d=google.com; s=arc-20160816; b=bQErkG30gwFlZDE4uLwL6ITBLWrz6YAas2Cz2MYXhyOr51+fPlotlCwIlWRqvH7bbM Sx+7aVbkNIjHZNTGuIF3lVSRjAP9MRAgaYaq+hQ/V4Y5ABv5korZOBN0jZU1irWRAFT5 qcFYJGQ9/u8s8NwYrh6Ty1/ZpOsg/2Bp2uHG4xgb86CxJLYYNXsURzq1UG/7Eb2EfmxR 0h+EzS+G+4aJNC4tTm7QuJbSBoPk0ix18JsWuU07XVJHArPu7HraFWdSp6BgZuh+MNbO MAAv7vz9/O9FayC3m36aY3jhPEOdGQP++fNfBJowQqRm9urgPqTbsx+DMOWBJVjGfDDb vW5g== 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=Mt38Rg+69y9F0WhJg90KFDq75afeisxh9S/U5FSskwg=; b=bUGutnCr0LN+NWpvCPbvwayZ6iM49oZ+AoVfMG+5thnfKZa/MVNv6AdBwiaKlPSj8X ZxdA6lrwryursG9Y8VN28q8IsII+WpK+1ynFNv2lKx0T2ZKlBZgE8Pnb21CfXn4JXAia Mo+2jaetWOaxH4Y4rZNEKyM51aEmSMNEQ5hPSipwbeGd22uhPWIvZirSheC9/RxmtRju 64JIYJeeOhzWeP398voEr4mMxCntLjtFcRWkKV5OB3e6qeKbj+DwcQ8S1GpFAfBVQIJh aNgCRdIaLDSL1qycfSqZ2dIa28prjfs9q8q7JwdeRhYcv3FJFZNOB9OO8rGcSnQWMcau NGtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d0MCTQhW; 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 j6si310205ljg.332.2021.05.12.09.19.35; Wed, 12 May 2021 09:20:05 -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=d0MCTQhW; 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 S238948AbhELQPW (ORCPT + 99 others); Wed, 12 May 2021 12:15:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:50072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233962AbhELPby (ORCPT ); Wed, 12 May 2021 11:31:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D84116198F; Wed, 12 May 2021 15:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832586; bh=yOs6+n/pwDzKey6fXcv5xl//oANFSztWXd2RNAaR3uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d0MCTQhWWsm+IIJDuiHvmpuEf3Kzfbx4YqLS+ZtZe/Zy8RMpAQsdOnkcDGT3RxQXF eEpO/QROqbMgc2JAqDnrzVMsaBwoagVtIdAYF5S+xOGPDRaxoR5HijzWk+q0sLycb8 Bj6J6Zj7aJNWFsWBhUqdbQdD10RenvnWtbS0Vy4U= 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 5.10 341/530] HSI: core: fix resource leaks in hsi_add_client_from_dt() Date: Wed, 12 May 2021 16:47:31 +0200 Message-Id: <20210512144830.999836966@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 47f0208aa7c3..a5f92e2889cb 100644 --- a/drivers/hsi/hsi_core.c +++ b/drivers/hsi/hsi_core.c @@ -210,8 +210,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", @@ -293,6 +291,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