Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1174328rwd; Thu, 18 May 2023 08:50:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4M2zHm6W3EiJurLSKQYzV7qa/SPfGSsVmbqnLLxzbhafuw9f66kt1vdJxnlt1PP2BHWJLT X-Received: by 2002:a05:6a20:e193:b0:f5:7035:99fa with SMTP id ks19-20020a056a20e19300b000f5703599famr14982pzb.57.1684425011570; Thu, 18 May 2023 08:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684425011; cv=none; d=google.com; s=arc-20160816; b=oPsJMMq+3Pebhley7XouudKAg74nblqss3t168/hKK4Saj0JJQxYv941zH6Ko/IVeF x3J1iYBh+F51OT+i5cwGZ8B5kstqJ7BMCoGeEU/ZYreAJQmpaRHwZhXwBeBtSqwcF9wY 4MFdAScJSqrAyYk/hsbAYwz+3Sk7hfHJdQSlqBBtUexv9JO6ehuSSo3av36ZSHjAk/CZ k04X2VUuxkaPjH2sCu1ipUpJIP/h++Q8hbLTYUMfRqfGkIkEe5cMMmF1BgGLrhMq/RCt m59bsIN9rqtSH6rS6Q5dZspNpIYoj2uGtx7w0zO4mFDMuONbjsZsGdv5R7dLWMFswfRv naPw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NDpb5Ha4ivNLgiiO+Ax/3NhCQbVV5MgVjXtVoyK70Bw=; b=Tj1nb6yAHtHZoUnZ1PIdRAIt+bDiZjRIPhlgplJ5LMOnzD6JtZLBik+evu/9Z0hIeo VleptkhTBCDt+qebItRDdYVj6Vjhp7WKcqgakGx/a5n94Kf70qcLkzIn2iKn9/sZ9B3Z KoBAqcgcb7craUC63gHB/GCdmzKW5NFOO9nNRfy/1myGndH+GLxzrkk18B1rFOOYgdBz cHTuxpqQfZ7niWfzdyLUl+l/kNSKgLtQ2K3ZeDo6zW4BsBz48WtJhK7sIMGQveh0bec0 EQlxqIAZrhke11fKrczuiUtR2bMm2Wj9KJ7675LaOy98FO77QQueRCCN2ZyKxFVpyK6h 1mKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=VTVOmCuo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e124-20020a636982000000b0051b15b58764si1663243pgc.343.2023.05.18.08.49.57; Thu, 18 May 2023 08:50:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=VTVOmCuo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbjERPEo (ORCPT + 99 others); Thu, 18 May 2023 11:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231487AbjERPER (ORCPT ); Thu, 18 May 2023 11:04:17 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C910B19BA for ; Thu, 18 May 2023 08:03:59 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34IBl9Gk018534; Thu, 18 May 2023 10:02:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=NDpb5Ha4ivNLgiiO+Ax/3NhCQbVV5MgVjXtVoyK70Bw=; b=VTVOmCuoH2nRtMoZQXsgWZl4NyutzptR8Po4MDKYqOfAT1qs07vAZ/SLU3xllQ0b0UxG wci6CGWk3t6edH4WzMYSsJ6Yk+svcu1ySuAwpsP/fmS3V9L/1GN8aWqP+oqQx53KnRsA m4iuBWSSfvzDKldb5wmplMZpu/dXbjHP7m7leAyW+qKhq6/6TP0Q9FVcYX8MxaDP6+yb RTlJlEHeDK4FUTaugA5C0vzBtZ4uFaE9aOBAk02th897rXRx7U0oXjRaFjVnrzm8M/Gj ePrUYoLMWIel7JDCiQMixEnRiFv8ytaMrZpa/7JBopKY/fNi3fDnHIA3TCMQL7NObu1u EA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3qngq1ghun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 10:02:51 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 18 May 2023 10:02:50 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 18 May 2023 10:02:50 -0500 Received: from edi-sw-dsktp-006.ad.cirrus.com (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.127]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 2C21015A2; Thu, 18 May 2023 15:02:50 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , Simon Trimmer , Richard Fitzgerald Subject: [PATCH 1/3] ASoC: cs35l56: Move DSP part string generation so that it is done only once Date: Thu, 18 May 2023 16:02:48 +0100 Message-ID: <20230518150250.1121006-2-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230518150250.1121006-1-rf@opensource.cirrus.com> References: <20230518150250.1121006-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: cPFI_s6E6LErWfHaMMWNtxjjOKU7s3cM X-Proofpoint-ORIG-GUID: cPFI_s6E6LErWfHaMMWNtxjjOKU7s3cM X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Simon Trimmer Each time we go through dsp_work() it does a devm_kasprintf() to allocate memory to hold the part name string. It's not strictly a memory leak because devm will free it all if the driver is removed. But we keep allocating more and more memory to hold the same string. Move the allocation so that it is performed after the version and secured state information is gathered and handle allocation errors. Signed-off-by: Simon Trimmer Signed-off-by: Richard Fitzgerald --- sound/soc/codecs/cs35l56.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index d1677d76d018..906aa416879b 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -837,12 +837,6 @@ static void cs35l56_dsp_work(struct work_struct *work) if (!cs35l56->init_done) return; - cs35l56->dsp.part = devm_kasprintf(cs35l56->dev, GFP_KERNEL, "cs35l56%s-%02x", - cs35l56->secured ? "s" : "", cs35l56->rev); - - if (!cs35l56->dsp.part) - return; - pm_runtime_get_sync(cs35l56->dev); /* @@ -1508,6 +1502,12 @@ int cs35l56_init(struct cs35l56_private *cs35l56) dev_info(cs35l56->dev, "Cirrus Logic CS35L56%s Rev %02X OTP%d\n", cs35l56->secured ? "s" : "", cs35l56->rev, otpid); + /* Populate the DSP information with the revision and security state */ + cs35l56->dsp.part = devm_kasprintf(cs35l56->dev, GFP_KERNEL, "cs35l56%s-%02x", + cs35l56->secured ? "s" : "", cs35l56->rev); + if (!cs35l56->dsp.part) + return -ENOMEM; + /* Wake source and *_BLOCKED interrupts default to unmasked, so mask them */ regmap_write(cs35l56->regmap, CS35L56_IRQ1_MASK_20, 0xffffffff); regmap_update_bits(cs35l56->regmap, CS35L56_IRQ1_MASK_1, -- 2.30.2