Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4742876pxj; Wed, 12 May 2021 12:11:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp3Qc+pfdhWq27KWz3e3vpwflpyH51FileidW9+butZLQ9IZUrouZaK6TgcabjKNGLV2tN X-Received: by 2002:a05:6402:14c1:: with SMTP id f1mr2621257edx.334.1620846663821; Wed, 12 May 2021 12:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620846663; cv=none; d=google.com; s=arc-20160816; b=uE8qXmyLnxWNdnpnbYy305x/mehVkEmdnqev7YJMp6o6fhKpKtAlou0Q3ra1jpqDan 4g7vdCvvJgwvgi3FCT6tZp6mrSwuNWI92D0/bziIFl+g9Ta+n+Lp57ID8NX3ZQ2XVDsZ U9Ml9c7r/utWEYb/BXKKXo3DDcE7hydL85oSd5QSXvxVVkWh/sJ0fql7vbNx63xcruBR az98OLbwmJRYIqAe9DQF5BSNae0AtBffSjVPsQSYIv7Yo41aAHwh/Q+sErkPSpSDiBlR 9ZReRX+juapCDUXyXcOXCVRuLOePf7/jUtK23uP/FPk6u2Y8zY9rd0B6jVQw2YphK4Ay lvpw== 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=In9t6xjWa3azjbuBtCQzDX6J7Vl2a/M7NLiJM+ZrNkk=; b=agicS63QDK9JV3VxPMFWKtiYYzBk4tHKVAo6JUjOenZ+Eiex5LkL0ojQd13ufKAX7T sTnxs+f+BoWFYLd/EwfxiTlPuztea2JtQ6IAFFY/gkE4auAx3duR2aDJB1OMPhWeU3wv FhachZMAYA/xEZTTX28TgcH94OQWpzotZXa3YZTqxMxUlq5WSbLTcSkkEnRqVQVC/sin czrKbFc4L+DuRLmF+v6gCltFEuTAuGw1TRT7/Jdl0lJF/AuPMW8/el6FyF+p4gqFQ5Xg J8rmYWNGke5nVgZ3DhGkKthvythavoUt/zcl2PBqqYGDUehpJbBELO2WJtEcW0Z7RZzz dmVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="W4/LG1i8"; 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 hr13si758284ejc.630.2021.05.12.12.10.39; Wed, 12 May 2021 12:11:03 -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="W4/LG1i8"; 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 S1358905AbhELSvA (ORCPT + 99 others); Wed, 12 May 2021 14:51:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:35800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243817AbhELQmH (ORCPT ); Wed, 12 May 2021 12:42:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C7BFB6198A; Wed, 12 May 2021 16:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620835641; bh=8pP1A/Z3joP6tttW7rxRtM+CVLi3bhO0g6klcO9ZeIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W4/LG1i80u8stBECS5BBN/LIGtZdBxPOxU9vfawQryO3fz66Y79HwuRXjLAl95LyF LkozMFAnizIHLlnib5C7CLeW2yYVT2zJ5AygCAcH9rozwl6d9I+wgApj5ZVCBQ15XW mYhLkC4ktnGzf1NlmdmL2UkQRBKQgbVf+vePA8K8= 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.12 427/677] HSI: core: fix resource leaks in hsi_add_client_from_dt() Date: Wed, 12 May 2021 16:47:53 +0200 Message-Id: <20210512144851.530874199@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@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 c3fb5beb846e..ec90713564e3 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