Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp636885pxj; Thu, 20 May 2021 18:36:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4LJJ4Gu5szyJYLlC5ncQskMuId5fL0WYEz3t2gI5PfL7hNkJ6bMuqKIrvvu/XqzoNyeaL X-Received: by 2002:a05:6602:14c8:: with SMTP id b8mr8180095iow.209.1621561003027; Thu, 20 May 2021 18:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621561003; cv=none; d=google.com; s=arc-20160816; b=djpwFt21hvoKZ7q5M6daRISBeQpMqAEG9qFo4UZMuE6/vNl5kAOLRcFe+o9GVz0kvC qPi6Drt2yD8TOh040d+lI1kZOgJnJaJ57ck6NhlieVMbGhnWAxutv+8JuQJBcopPizFJ AiDOjZgYPfvVSFb+owd+hWcTUpMn23cWX7WJdrnLNtIMl1VRi170/pR/YifFPC5aw4z1 Ih8wbfKLnnpD3j6YT5m5w4mOJiL7boru7PCWQx+/3zfFy/zQ2KZSO6amTuotLdxOdVV1 K2Iaj3a4a84gaBMQsheJZjjPRlvVf1Bjud0zwgOjhdaqiJNX+pRoFNef7YdCpmgZmky+ Yprw== 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=FHlDFHYlB0I72HSyPwIX2FOytXnBZBWPBkgbYFq1Pvg=; b=MPdZAL6Zh8E3FcpS25gUMmIUfsvXa5eGTSMVDvNS4OXwjuttMFdsDFpDQuYj/Nkws1 dtEAUkS9bCVbCEsWvWTJxqINpGHPQ+DwkgPM6o0t63OV8QYccUXDw+2LhAU5DzC7x41j 5f0uBL68P31aiIjnJ/reSFlYhpAEa8rI9vS+FhyJFU1FqHMJZz1JShnGy9aVCm0Pihii kFXAW+uhYXygvqJn9oR5Rw3zsv/1E2/0fBpH3g5eA/0wOPMTINTzntDRxoVUSxKjOXTV YB7dggxOZHN9ZuAqprdlG5kMxSTh6aK1/Vgt31xDRjexLmbQGOpbk/qa9kHBpTU3Uoa1 0dzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NQxP5pmI; 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 h10si5171347ili.90.2021.05.20.18.36.30; Thu, 20 May 2021 18:36:43 -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=NQxP5pmI; 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 S242833AbhETLmG (ORCPT + 99 others); Thu, 20 May 2021 07:42:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:44012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240612AbhETLVI (ORCPT ); Thu, 20 May 2021 07:21:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3664861D8B; Thu, 20 May 2021 10:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505478; bh=Ib3Rf7fOtI18G1hLrQ1hr2G3Y9ChlM74GR7dIzqlUmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NQxP5pmIh/dvoDNnEfBUT+NkWDGU+RJntoTxmW/2gCmYQohATVsvjcuoPNlNEP1TN 2yVkvCf3mdPrVJGSO3e5r7yQAMFpnbgJ0Ms2Dxz7JHk4lejFgmM6uXePwy2by+4usm nBbI2w3YWhb8+9DAaDgKJzq56/o4/9DdZ7O9Rs0I= 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.4 109/190] HSI: core: fix resource leaks in hsi_add_client_from_dt() Date: Thu, 20 May 2021 11:22:53 +0200 Message-Id: <20210520092105.794467347@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/hsi/hsi.c b/drivers/hsi/hsi.c index df380d55c58f..55e36fcd7ff3 100644 --- a/drivers/hsi/hsi.c +++ b/drivers/hsi/hsi.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", @@ -307,6 +305,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