Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4636784iob; Sun, 8 May 2022 20:07:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh6aZtG5yS09/Yz4DbJfGy1rpCwmva+dkVyMToUmDSplzCJF8Q562Ooj3eXtI8yiWPM+i1 X-Received: by 2002:a63:9043:0:b0:3c6:3550:6467 with SMTP id a64-20020a639043000000b003c635506467mr11487421pge.521.1652065645878; Sun, 08 May 2022 20:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652065645; cv=none; d=google.com; s=arc-20160816; b=N6P2io757WgwIiNaVjU0xlGP+GwHYzUcL0FjQGAP6yqqUtwQQDo+k7+VYRKB/IeJE+ TeotmrrI5/BPQhK2qKt7SEcRDkdjjnxpoWOIoiwcIkO4PyOQpRjo5klryQC0hVVAkHSp CFhNi1NYe60j27zIX6NyglwOSB/cJpyNFab+RL02zARrdtCCnD9vvcDFqWzIkV2FhzLR u81SMho/rtqqr4ZGJ7EEVyiw3sChXCQRkMMsR+9Y3kvb0pw0hs/8AluwF9vBijS1xI9+ 7XMTH/iMGTRz9NaRQCl2I7OiqPIGpQHJZ9Up2+xMMoj/jGR4NeKQUHEbd1PiBIlUB7SL pq8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Kq/Z8Eu7SYNiz5MUjUzvhIS5G1c7BzRPRvFl7aaXh+0=; b=sVnADpiKHDcVuVQmw94KQv6YOhzsnXN/FTcZGmcpV1G40KnEzedFU4IytbQ4M8XflZ CD2zx4pc4Vo0HBKXB4U3MicTpxgmCn+2viQHtD+LIwQVmyZynMyeD2sbR6tB2xnokhMt iHPaMiR57ycsfBdzwKDWmHqN3bT4gFIQcrI6w7miLkPLHFnFPhR4z+rz79FcJe1kKBHY V4KCZKudJQVmsoySwKSHbKvSyHQKE+Agggwo7lupZEIg6jemDpOZ4G+o1nDNHtOZcMlx rU5DDxDuweWHOL2LSh+PmlueDGwZC6eA+ZLEVQEOcKWngTZfhZnuLCOwMg0vZSHDB19B k9QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="GawM/MbZ"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o17-20020a170902d4d100b00153b2d164b7si11524223plg.191.2022.05.08.20.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:07:25 -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=@gmail.com header.s=20210112 header.b="GawM/MbZ"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B9F778071D; Sun, 8 May 2022 20:05:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344853AbiEFEsB (ORCPT + 99 others); Fri, 6 May 2022 00:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbiEFEr5 (ORCPT ); Fri, 6 May 2022 00:47:57 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 004AB580DA for ; Thu, 5 May 2022 21:44:15 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id s14so6328312plk.8 for ; Thu, 05 May 2022 21:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Kq/Z8Eu7SYNiz5MUjUzvhIS5G1c7BzRPRvFl7aaXh+0=; b=GawM/MbZQdX0Vx7RCXLe5rZU11ZFRdq3erkTMZM03251cxj/+0eOyJTlgPaoSQ6lj7 aJXyyeX2sqmlmEudrNMS1+C4SH1K2aroqYpVAlqYoIQGg3yqxqcZENe9fAslw5VcG8ip FITqZJo5NuwCiLiTCaDobXYQtRbG7hhhlKIqPhpQYtQJIKrkj3IxitgKuRYtBFt4um+b 1k7Cc1JOyoEecxXLGVQnrA2WXL+/ECZzqJeSMxs3eXH9WzFpJ9+mvJESou+UAmZ3prtr HXF4NQOv2Eg8whkdz9sDvWVdRPZEYoHuqXbxiUiOjoS1mT4D0rErWa/+2MRiYb35k/DT 1M0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Kq/Z8Eu7SYNiz5MUjUzvhIS5G1c7BzRPRvFl7aaXh+0=; b=joqo2C2LjQRngEaxgPA1dtPdXSpCm/imP6tx0/tARekUwdrGY/+xIiGJbeFegWlXXI wtluIXwRR+w7mOaPA+Y4sXyAtvvrDDw+Z2gBm6av877R26gHePzZANMHxRQorq8VvIBv yfbm9yk1NVS0TqvIqys0Q0oqVvNbI6y+QMQ27cKS09X5o1ZhG2AbHeHKLyqcK+nwx9DP AFF4PbdlqGZRDMEMHU9vYcQyF5mRXmlp0prZ6PAhGjpHIEvbAZPJktc4ympFTKl7d6NH 57YRNegqEORWNIqG7P1bYaZPUgLszEimDxe+14rdfyhqKLEG3M7W8JfWdE7BtDIpf3IQ Ox5w== X-Gm-Message-State: AOAM533lofMl7b0odGVoUngjxnG9Znqv6YJsjAEZzaXBYaMXSZoMesm1 NMzbuG/ZhdFgaYF+x0zyvJM= X-Received: by 2002:a17:90a:528f:b0:1dc:9a7c:4a3 with SMTP id w15-20020a17090a528f00b001dc9a7c04a3mr2023445pjh.112.1651812255491; Thu, 05 May 2022 21:44:15 -0700 (PDT) Received: from localhost.localdomain ([183.14.31.73]) by smtp.gmail.com with ESMTPSA id g2-20020a170902868200b0015e8d4eb273sm513770plo.189.2022.05.05.21.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 21:44:14 -0700 (PDT) From: Puyou Lu To: puyou.lu@gmail.com Cc: akpm@linux-foundation.org, andy@kernel.org, chris@chrisdown.name, keescook@chromium.org, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, pmladek@suse.com Subject: [PATCH] lib/string_helpers: add allocated strarray to device's resource list. Date: Fri, 6 May 2022 12:44:09 +0800 Message-Id: <20220506044409.30066-1-puyou.lu@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220506032333.28249-1-puyou.lu@gmail.com> References: <20220506032333.28249-1-puyou.lu@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 This is a must to automatically release strarray when the device disappears. Signed-off-by: Puyou Lu --- lib/string_helpers.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/string_helpers.c b/lib/string_helpers.c index 4f877e9551d5..5ed3beb066e6 100644 --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -757,6 +757,9 @@ char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n) return ERR_PTR(-ENOMEM); } + ptr->n = n; + devres_add(dev, ptr); + return ptr->array; } EXPORT_SYMBOL_GPL(devm_kasprintf_strarray); -- 2.17.1