Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2195205iof; Tue, 7 Jun 2022 22:51:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykqd9r5sg9X6Jr6eCIhNTcB5OKxpvNY3kszWOMf6OFWqR+QtWtqcNFwvkDdA71x9QaFQad X-Received: by 2002:a17:902:e851:b0:166:381f:633 with SMTP id t17-20020a170902e85100b00166381f0633mr32080854plg.163.1654667468889; Tue, 07 Jun 2022 22:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667468; cv=none; d=google.com; s=arc-20160816; b=q9fZz2wJl0PzKqLUOrSY42g/fl11JpzH6bhOzQ3QyogKIlqqc6+lr5wLbJLYeRgDyH 2l099W3NPZ2LLDZqtcOTnI6seYuPf1vLqBOp6DArdVlC4ZW+6uiZBAILMzZ407a1NBcQ Zc/MsNUTkUK0QFNyyjrGx3Wxr/NYWNyFZef+iQsPflEv3LnTI4tiv2kz9TGFFzoS4a5S fjvpaPMqAbI9e4aPbzUtsmtyMasVIqVXd+tttdWZuOoc6OuIz7EAMvRK0DLqgbsJYE9Z cAtVUwUsKe8dR2h43eK62x+vZbLAUeQ7Z3t/0mscEDmEgfiyKsk1CdyRpn/wnyq9rO09 3HKw== 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=oNrsyyTbwpZydF1DVO8NHDMYsLCGuAeOU77FdVrkAPw=; b=bscCoq4Gaq3knL0z5lDlMPQopKqCzXa7nsHTFGDSjHh4Kj9xel/hk3y1+Le2iTIFBd xIzknvMBjdphhLELG0xHfjLzXhimptfF+rn8uyXIEuS1jLHCQY4thujmKeTcd1iCLUQ2 ns+NCSpY+h4avfoCXx1AZCSSCdjxXhuaz5iyTBnAoU5OykuVX7Mm9b4huOGKxAJ72zLT jb1ZeoxRogsK5AJpqwO9SV00cxQWG54pw5Xreo/DTS/wLBNa1ZMqAqIV0UNXC/Iq9Zd1 kKvQB1lA3yAszD6fj66xFiF75t32WZkd3DiuNllMYqwLTlH6FqMgVgcfE97bim9y9twk r3hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qfQdgLrf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i64-20020a638743000000b003fdcbced657si4339156pge.860.2022.06.07.22.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qfQdgLrf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A3E9346D6F8; Tue, 7 Jun 2022 22:17:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392005AbiFHArJ (ORCPT + 99 others); Tue, 7 Jun 2022 20:47:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358975AbiFGW1X (ORCPT ); Tue, 7 Jun 2022 18:27:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEC72722B8; Tue, 7 Jun 2022 12:23:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A873DB823CC; Tue, 7 Jun 2022 19:23:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3F8BC385A5; Tue, 7 Jun 2022 19:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629805; bh=/dvj1yLBraTRfb7jibzxDZgOea9b9knsNdoqbo1WkrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfQdgLrfyeBrs/hHPpT8K5SYuApW5xjR/zgzbnl+3cpxRcDotUGgrQaVXEGRnarlg addFCpK7cr9wZd+dMIV8YnKUiCmLUdctYStaY7THD2OV+6PhFbbuzeW8Tbtb6ZRxIi 0vqHAl8ZCtPwQCEDWJ/lqt5DIOHI3gYCxQl3c/YY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Puyou Lu , Andy Shevchenko , Linus Walleij , Tejun Heo , Andrew Morton Subject: [PATCH 5.18 806/879] lib/string_helpers: fix not adding strarray to devices resource list Date: Tue, 7 Jun 2022 19:05:24 +0200 Message-Id: <20220607165026.253151949@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Puyou Lu commit cd290a9839cee2f6641558877e707bd373c8f6f1 upstream. Add allocated strarray to device's resource list. This is a must to automatically release strarray when the device disappears. Without this fix we have a memory leak in the few drivers which use devm_kasprintf_strarray(). Link: https://lkml.kernel.org/r/20220506044409.30066-1-puyou.lu@gmail.com Link: https://lkml.kernel.org/r/20220506073623.2679-1-puyou.lu@gmail.com Fixes: acdb89b6c87a ("lib/string_helpers: Introduce managed variant of kasprintf_strarray()") Signed-off-by: Puyou Lu Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij Cc: Tejun Heo Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- lib/string_helpers.c | 3 +++ 1 file changed, 3 insertions(+) --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -757,6 +757,9 @@ char **devm_kasprintf_strarray(struct de return ERR_PTR(-ENOMEM); } + ptr->n = n; + devres_add(dev, ptr); + return ptr->array; } EXPORT_SYMBOL_GPL(devm_kasprintf_strarray);