Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2213993rdh; Tue, 26 Sep 2023 16:51:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGK2WR9swKYOq/0wr3FrSzJVQyq6zJNng20FdwsQGnFh9zugNCySmSt+gsS10iCJgMSsmQY X-Received: by 2002:a17:902:ec82:b0:1c5:fdb1:e585 with SMTP id x2-20020a170902ec8200b001c5fdb1e585mr296068plg.21.1695772286068; Tue, 26 Sep 2023 16:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695772286; cv=none; d=google.com; s=arc-20160816; b=q65QH00dLS0pJMW22cqJJbI7U2EkmqZP210QwmcsSDwSRiUTaWXuYlpvKjWTIcwgkC faSTAzurXDHXuWCgzUX8D3Vzc1WSLprwUXp47ZfyYanaLBfMAnkCMXa9Ys6EGy3Gk/XU sX4J5T3vaIj+zzOFDbLJ7T0Al3r2LBkgKVTg7MKL9hLPOX2VWlUvd1GgGOHYdmH/Ea09 LjvLPntfoOEXViQ5TYEhTsDA9SH/lQ7vV06/pYqtMIY5Xhc6lmAoTruzKPo90IdzaOz/ OPacxauilmLf3zZQ0rAHwQo4wTeYcq+m+YPKMoAGSuHTWFuYWN9/lxW6oyl7DIzLl6D4 ctWw== 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=bU5dbp4PmbcRGMxxeBcidbIs/vd32ofMq8iILiK+4+o=; fh=SVLtJx2RN624E9ZvR+iL8AVfiRfKB4Yg6A8iu4u1uGc=; b=gTT9iZfwSvVdAzaoou1Q6ub/Ap9b3rySQxX0hw/oO1NimpHdiIMPbUdNHlKEsPoPFO SMhLIjdhn2JcUfw9Z+W+B5Efg7W1egfpDDGi1TPwmGQF4Tj99B/UL6d1vOl88XNrqtwB /Kj0IefvBDezPmmoL3+o2QMCru2oqgU2/iFcHaQB5lKDGlxuBrTlKvZlviL0gdkGAhUA jsFbb5GnJdPslDQT0hUfwgkZFTw82vTtXg1NR2qIN0z9IKPFqP2/t6H2W8zZvNKM08io evQ1Mgq0RP8QWb4YKjDDTpGOAzLvshOE2HC6et9gRDYdGjr24iT9woCTo2VRRFd+lqif T/8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARFByj3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id la3-20020a170902fa0300b001c20e55153esi6393522plb.496.2023.09.26.16.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 16:51:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARFByj3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EF84D81C7AB6; Tue, 26 Sep 2023 09:40:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233309AbjIZQk1 (ORCPT + 99 others); Tue, 26 Sep 2023 12:40:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235275AbjIZQkY (ORCPT ); Tue, 26 Sep 2023 12:40:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1760BBF for ; Tue, 26 Sep 2023 09:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695746377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bU5dbp4PmbcRGMxxeBcidbIs/vd32ofMq8iILiK+4+o=; b=ARFByj3pfgy0AiNK5oJAen2kPF2j/FX1q5YlaHDVS+HZraaCEijScvwrp1ld/IwWLdXvSm Psk9dQdO7pV2hM+mumRPDKdcB5LGU7gmVgpwYkFZYSgmlO4cbqtvrd7tUAbUBmxjay0foG PvlkJhPod502MdIbEwRQgKiknvezpvk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-5iiAPVJmMaOMeNLyWTZ79A-1; Tue, 26 Sep 2023 12:39:36 -0400 X-MC-Unique: 5iiAPVJmMaOMeNLyWTZ79A-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4054743df06so69287955e9.3 for ; Tue, 26 Sep 2023 09:39:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695746375; x=1696351175; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bU5dbp4PmbcRGMxxeBcidbIs/vd32ofMq8iILiK+4+o=; b=PqHOjkzPmQshVyFTLOR7otdGFIb6D35xZgU5FShOIgv0SDT2PyzYTd9q/aMWrD1nRN FKW869kskNvV0wt12vcdxHc4E8PSYHknFUmaA4ZV7ziFQlb8XNw/OMrh71SQihHPg95u XmuFWowNunWDswRKJXpU8+1GGFR4u878lTsRUqjAsVup3y9uFi767IrDH3+t9r5SQsr7 JS3XS9EnNQ/p6YiQQuROnISfYXIUkayzMfopO2G1EDJ0oEjocgCpJUMNCeLIiXG7XEoN nh3Pxpz47H087zNUveKM/netHti64wF95YcSXbr7PlNH8RHz5aWIPgZt6MObOofZN9/O iHHA== X-Gm-Message-State: AOJu0Yw5mM470bXbNhAiJJnXlS3Ya/6eMMf0PleF0+os6ThwDVE+6F/4 zMvDMclamQDnlsbZUMFcSeJmdGVv6kCcusgzBy78TM4MuasIZGo7I95Cq769wWy6r77mbIqcAIR W0r85YRJ5PNh/xsSxyvpFEMQ= X-Received: by 2002:a5d:4a12:0:b0:319:5a7c:6418 with SMTP id m18-20020a5d4a12000000b003195a7c6418mr10305779wrq.43.1695746375047; Tue, 26 Sep 2023 09:39:35 -0700 (PDT) X-Received: by 2002:a5d:4a12:0:b0:319:5a7c:6418 with SMTP id m18-20020a5d4a12000000b003195a7c6418mr10305767wrq.43.1695746374845; Tue, 26 Sep 2023 09:39:34 -0700 (PDT) Received: from klayman.redhat.com (net-2-34-30-58.cust.vodafonedsl.it. [2.34.30.58]) by smtp.gmail.com with ESMTPSA id w10-20020adfde8a000000b0031fba0a746bsm15171803wrl.9.2023.09.26.09.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 09:39:34 -0700 (PDT) From: Marco Pagani To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix Cc: Marco Pagani , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, Jinjie Ruan Subject: [PATCH 3/4] fpga: add a platform driver to the FPGA Bridge test suite Date: Tue, 26 Sep 2023 18:39:10 +0200 Message-ID: <20230926163911.66114-4-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230926163911.66114-1-marpagan@redhat.com> References: <20230926163911.66114-1-marpagan@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 26 Sep 2023 09:40:28 -0700 (PDT) Register a minimal platform driver associated with the parent platform device used for testing to prevent a null-ptr-deref when try_module_get() is called by __fpga_bridge_get(). Fixes: 9e6823481e5f ("fpga: add an initial KUnit suite for the FPGA Bridge") Reported-by: Jinjie Ruan Signed-off-by: Marco Pagani --- drivers/fpga/tests/fpga-bridge-test.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/tests/fpga-bridge-test.c b/drivers/fpga/tests/fpga-bridge-test.c index 1d258002cdd7..4bd4ecaa7e90 100644 --- a/drivers/fpga/tests/fpga-bridge-test.c +++ b/drivers/fpga/tests/fpga-bridge-test.c @@ -13,6 +13,8 @@ #include #include +#include "fpga-test-helpers.h" + struct bridge_stats { bool enable; }; @@ -53,7 +55,7 @@ static struct bridge_ctx *register_test_bridge(struct kunit *test) ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); - ctx->pdev = platform_device_register_simple("bridge_pdev", PLATFORM_DEVID_AUTO, NULL, 0); + ctx->pdev = platform_device_register_simple(TEST_PDEV_NAME, PLATFORM_DEVID_AUTO, NULL, 0); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->pdev); ctx->bridge = fpga_bridge_register(&ctx->pdev->dev, "Fake FPGA bridge", &fake_bridge_ops, @@ -144,6 +146,18 @@ static void fpga_bridge_test_get_put_list(struct kunit *test) unregister_test_bridge(ctx_1); } +TEST_PLATFORM_DRIVER(test_platform_driver); + +static int fpga_bridge_test_suite_init(struct kunit_suite *suite) +{ + return platform_driver_register(&test_platform_driver); +} + +static void fpga_bridge_test_suite_exit(struct kunit_suite *suite) +{ + platform_driver_unregister(&test_platform_driver); +} + static int fpga_bridge_test_init(struct kunit *test) { test->priv = register_test_bridge(test); @@ -165,6 +179,8 @@ static struct kunit_case fpga_bridge_test_cases[] = { static struct kunit_suite fpga_bridge_suite = { .name = "fpga_bridge", + .suite_init = fpga_bridge_test_suite_init, + .suite_exit = fpga_bridge_test_suite_exit, .init = fpga_bridge_test_init, .exit = fpga_bridge_test_exit, .test_cases = fpga_bridge_test_cases, -- 2.41.0