Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2592691iob; Fri, 6 May 2022 06:26:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQBVr1HkMIDe8UJ5u0JGdbgDO2eTW6PPAnJnEh99jjCJyk/ntmyGeCEeq6dL3u2KyPp6Ym X-Received: by 2002:aa7:83d0:0:b0:50c:eb2b:8e8a with SMTP id j16-20020aa783d0000000b0050ceb2b8e8amr3638126pfn.31.1651843584852; Fri, 06 May 2022 06:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651843584; cv=none; d=google.com; s=arc-20160816; b=fx1Y/Y6uDuRIP6+q/CHfTCNrRowqDrKnBevi1gIF1i5d6OC+Frhk+fJUntZGMrDrr5 aNUdYkfduvQxtPPPvv/LRu1OJzgX7CvBhrbZ0rTuJrAFSaUD8/TsF3RnxFIUL8taltOd HPDV2fb7wKonU5N3eSJy6YY+VvHWwnTZjoqPr3pwU8n1PdfQEA+BIk0KX9bvAvsN6c0K J9rr1+FQrMY7AG4yR0e/iPEk835QIZg6kMUFejwZzLea+XgheLfqW3BmU9KPZ7dzNjYE yFZ5lWjjrkWN7pHgPB/MlndpG5iQx/qCDBylmZzy94JL35HvTUp6b9T+fMd59a1H/yZW 5Z1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:message-id:date:subject:cc:from :dkim-signature; bh=Cnmywrnu3rViVjyjTrHy7lr2MEpFSHL0j0EcHBkWfz8=; b=MSlarYG7sWUBK9Hd6qZNhpT/d+Hd9fJqCyRWTiTDv1IKT6A6ku23EXlUjEzlUse6ho ezGaK/SgZnSCqtyWbplDz5FLhdNNyp/71iqoo3mIHMnQpoO198biRzQZAyFxvtvKamhg 7H6Mp5fejf9YZPYSkY1jkLy5AQzkk8yttaniYknA2xxUhBfdLg4pVvjAtxKfUH7n/o5Z I9UXjpbdRfeFHmaxanb8HP9EVcaYUZ9fwB711Rq+WrzVZNDNvBvOtd3iC/BZuV/zJbSz prvvG14vhSiUG882e4BrFUZQu5zLf9iwIC/PYU53ykXWNcJuEBcUaW/VL0mJG2v3xRrP wGNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=dUA8gSxG; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 83-20020a630456000000b003aa55fc2ad0si3705172pge.501.2022.05.06.06.26.09; Fri, 06 May 2022 06:26:24 -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=fail header.i=@gmail.com header.s=20210112 header.b=dUA8gSxG; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389603AbiEFHkX (ORCPT + 99 others); Fri, 6 May 2022 03:40:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242343AbiEFHkV (ORCPT ); Fri, 6 May 2022 03:40:21 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2CE25DA30 for ; Fri, 6 May 2022 00:36:39 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id k14so5508648pga.0 for ; Fri, 06 May 2022 00:36:39 -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; bh=Cnmywrnu3rViVjyjTrHy7lr2MEpFSHL0j0EcHBkWfz8=; b=dUA8gSxGEQ9vHr09a0i1aEK396Fru+x1xgG6lcOuLbrbdXrlXO73Deu+tXev/47/w2 O6CAD3cpSK4puLXMs1wgSDOCrmSM5wR6UbSafgLAGP7WQfvSmUgI1Bs2Uv9VWo6yQKHK wNJLigIDgVTMz6bcnTxtYMIImrpes1myrc1BXR1OBlXjAyEaJp6WqIvh5uO7mk96J7wd 79HWxOkFMPM310Nv/rhfDaWsnHYcuD9BDgr8DwJdlgDfnctp9WCPcoyR1eTjMIqcqXpn ZkQB++rABNTGAukfsFUwIRKqYep8OX2QP6lSO0fWNxcxdaOyrz2ExdBgIJQAEP5QTfce UKhw== 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; bh=Cnmywrnu3rViVjyjTrHy7lr2MEpFSHL0j0EcHBkWfz8=; b=7mKJCXhITTNn56i1mpFAR4tEi+xoVh3hU+PZcZTtV8ZPiGBcgBXIvUsz69ffnnkFop KPxOGK6YTBz4Rk5loye9GAh5KdChEC5fa5mfls1swIjqg6EPXf01K3Q+doee7t7dbEYP hwO+Ra//AR48Rz3CONjSCrvVl+tH3aO4saXJWWLAJl3zvEjhNZfo9KHogveL7SFz1j5k rx2leQFwea8G/VoOFUaiO72DUL13l8Ct0yMsR8LbpC/cUQoAfnsYv3esyYQzSuuQ95Y9 JYDL2kHGTK5DbPCb00Tt+mCDZJ3vu8JdcwMeoiuBWguBoDUag/pBqlJvZEa0P6cYgmRw LJ8w== X-Gm-Message-State: AOAM530gEe9EhiWHb12QfIpbQaRdBnvv07ikrUuo8blMxbsY9TDqnQBm nGdqNXVOyzj8s9MvFNnVPLk= X-Received: by 2002:a05:6a00:1490:b0:50d:f304:61ea with SMTP id v16-20020a056a00149000b0050df30461eamr2023749pfu.73.1651822599127; Fri, 06 May 2022 00:36:39 -0700 (PDT) Received: from localhost.localdomain ([183.14.31.73]) by smtp.gmail.com with ESMTPSA id n2-20020a170902e54200b0015e8d4eb236sm949190plf.128.2022.05.06.00.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 00:36:37 -0700 (PDT) From: Puyou Lu Cc: Puyou Lu , Andy Shevchenko , Andrew Morton , Kees Cook , Petr Mladek , Linus Walleij , Guenter Roeck , Chris Down , linux-kernel@vger.kernel.org Subject: [PATCH v2] lib/string_helpers: fix not adding strarray to device's resource list. Date: Fri, 6 May 2022 15:36:22 +0800 Message-Id: <20220506073623.2679-1-puyou.lu@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add allocated strarray to device's resource list. This is a must to automatically release strarray when the device disappears. Fixes: acdb89b6c87a ("lib/string_helpers: Introduce managed variant of kasprintf_strarray()") Signed-off-by: Puyou Lu --- Change since v1: also set 'n' of strarray https://lore.kernel.org/lkml/20220506022845.26750-1-puyou.lu@gmail.com/ --- 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