Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp669323rdb; Tue, 23 Jan 2024 10:57:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGP91/oyGeTUtrqqOxnfrehcOVbQFuRmiOW+W6UMb8sZUZ91n7x+nNOBFV8kxRqxzeHE8vP X-Received: by 2002:a0c:e44e:0:b0:681:9467:bdf6 with SMTP id d14-20020a0ce44e000000b006819467bdf6mr1130188qvm.44.1706036223192; Tue, 23 Jan 2024 10:57:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706036223; cv=pass; d=google.com; s=arc-20160816; b=NTnEIGBJlFrvAATGZ5OcL4xc/rAWFGRAM7hTatAJwTcj5CHwGi8W2kJ6EFelhTKyVS qh0HpcTZDChYCCJ05gC66ocJ3JEcSFRAe6QouRl33G/L8NgHIqoIFnFl56wBe6kPiio5 RZK8eDzm0eP3GoQVx9o8Z6RfY15RiquXXVKVwfdX+qYYnQNnDvk+mZi1lL3O9nZzWdRr rZf9Wut88ntgwfMoijcSXIR1RLyxx2gZZyYPK/dbsI1ELBxKBJLaTwj8FsnB25mYWmnZ HCoSIr9sB4xAVTF7cH9aq5An0LZdsSvbltoraoo1qyjEnrPKscZIcMhti4cgWyHBJsky H4pw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cks8pS5hSxVEyXiud0SjS0OKfm6VxHIx7O3Mv8onWLs=; fh=26fOig74KkB7hULuYNgHMDbW8F00rUC5uFYx3bIWP/A=; b=Ii1Lj+hSO1iJubjRUdccoa7slrkaxS9GHhKlIqzCW0O+gnUowr6QIHEuxqaWghRSp7 ExkbdHfRzoJmGqBrrtoD/JCjUehrKorlGJBZ1roxbv+zqT2nsHoGhtZfu6TDls3sG+XE xgbcK4RcT8xMXoFAWWCtN6N17qAbFGoraBTzYbBQMKs+lj+8NOjnFsInoqqBE9D9F4us ZG3uNTU2ujkDg1dseYZEre/9ufjxx+JiaC2CowWG7HQN3nNSfTOJrCtNtayKVEzqBfSi ljODH6HoCM/srod9+5ZQPCxZiQTaR9PgEfLLLf/HPKA9k9nRc9qa4G9d8Ct+haEeUFs4 muiw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CeY8wlcN; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35921-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v6-20020a0c9c06000000b0067f60ad441bsi8538628qve.88.2024.01.23.10.57.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 10:57:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35921-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CeY8wlcN; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35921-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EA2FB1C22533 for ; Tue, 23 Jan 2024 18:57:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 326B81272CB; Tue, 23 Jan 2024 18:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="CeY8wlcN" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7DF786AF1; Tue, 23 Jan 2024 18:49:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706035761; cv=none; b=EaivFsFu3Lt7yPexER5BIrLzAedvQZ33BQIqp4jQm86l/U5K6LtguUUWu2iE4GvThJZYouu3kmSqhtYar8O3s/s0zX/fF0fdc9CHeCKd4yhAqZOfFeLPirSxcR4/apXJQ9AVIsq/MwIR/BKoQpvWys1Dekwg+QZDX2etGbZeuFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706035761; c=relaxed/simple; bh=ql2DF2gWb+wb/Fw+2uQLzt/qeLwBL6iqApd/BenJUHs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tVzcV4AMr4fD7/4yA+qCGIqjYZ8pdtwyl20kBPI7oXNnXDtZMDkd4Q3hB5k/fhn3Lb2m2okE5zo5bidmbiXw/8M9xP2vQSWxYP/mLsPYSRUkVy84Iw+0WIhabz70RysjmNeC/Zq2Gov4jYGKQf1u60V3wbwxy8YKwdrfTuK9gSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=CeY8wlcN; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NInFI3112948; Tue, 23 Jan 2024 12:49:15 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706035755; bh=cks8pS5hSxVEyXiud0SjS0OKfm6VxHIx7O3Mv8onWLs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CeY8wlcNvdB3VNGFpbhMHoSLkAzN/RlcfK+0iaTVgBEa52FZjIQRYVru7rlLmliIu zQXfc6B+hVx25bOZF18Cq/r82jgOoLciSlrom7B+eXaresBXw8fSjogL6YjNVkdZ99 2KcQ3ClPzyqAMBJ8Hegx6tSSTgY+p9tlqaFgRm4A= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NInFUY128522 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 12:49:15 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 23 Jan 2024 12:49:15 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 23 Jan 2024 12:49:15 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 40NInEnK066395; Tue, 23 Jan 2024 12:49:14 -0600 From: Andrew Davis To: Jai Luthra , Hari Nagalla , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH 3/8] remoteproc: k3-dsp: Use devm_kcalloc() helper Date: Tue, 23 Jan 2024 12:49:08 -0600 Message-ID: <20240123184913.725435-3-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123184913.725435-1-afd@ti.com> References: <20240123184913.725435-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Use a device lifecycle managed action to free memory. This helps prevent mistakes like freeing out of order in cleanup functions and forgetting to free on error paths. Signed-off-by: Andrew Davis --- drivers/remoteproc/ti_k3_dsp_remoteproc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 0cb00146fe977..a13552c71f440 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -591,7 +591,7 @@ static int k3_dsp_reserved_mem_init(struct k3_dsp_rproc *kproc) return ret; num_rmems--; - kproc->rmem = kcalloc(num_rmems, sizeof(*kproc->rmem), GFP_KERNEL); + kproc->rmem = devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KERNEL); if (!kproc->rmem) return -ENOMEM; @@ -635,7 +635,6 @@ static int k3_dsp_reserved_mem_init(struct k3_dsp_rproc *kproc) unmap_rmem: for (i--; i >= 0; i--) iounmap(kproc->rmem[i].cpu_addr); - kfree(kproc->rmem); return ret; } @@ -645,7 +644,6 @@ static void k3_dsp_reserved_mem_exit(struct k3_dsp_rproc *kproc) for (i = 0; i < kproc->num_rmems; i++) iounmap(kproc->rmem[i].cpu_addr); - kfree(kproc->rmem); } static -- 2.39.2