From patchwork Wed Oct 6 02:42:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeroen de Borst X-Patchwork-Id: 12538365 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A86CFC433EF for ; Wed, 6 Oct 2021 02:42:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F3EF61130 for ; Wed, 6 Oct 2021 02:42:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237217AbhJFCoS (ORCPT ); Tue, 5 Oct 2021 22:44:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbhJFCoS (ORCPT ); Tue, 5 Oct 2021 22:44:18 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9187C061749 for ; Tue, 5 Oct 2021 19:42:26 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id a16-20020a63d410000000b00268ebc7f4faso742869pgh.17 for ; Tue, 05 Oct 2021 19:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=lXh9uBOfLTRnEX/C53DJjD07NPHJmE4SotDbW0uoTtg=; b=QTMeRIKT5IxshLxL5kzXWJkus/8v94KLZsNNmW6erEmg5Hay4oPyYskxUkvpdlKSdn FSXTsqNtq7YVp41qDQHZA9UU2DKSgIVVmQ4lcohZPjGF1wP+tMFsKNpAXepjs/f67O0V B289ckvlxFpbWBgUQeYZN2W0kfm0zM0NzfNJsebp6npddWmV63ML4VgG56TXPi7/kUxx QhXOrJWwxDopKDMB554q5viQ76U8kTSaj42KHFaGlpPldQBkOTMOTjjugMY94tRwchPB 7OkTzsK/6gvB5G4iFFdW6uoCXShAgU5scSg13kIy5R2RfJAgB2pvWgqWu4dAQn++qj9O 1ZNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=lXh9uBOfLTRnEX/C53DJjD07NPHJmE4SotDbW0uoTtg=; b=KC+5G6CnmWF6MMAt4j10LItOWZteYMzvvEiyfqtIfdCCbcI3kWppy5xLJWxQtX+Xqz +KSoNplhzqs7ZrgKZ2rjXCLf96uP7iMDZZbmwEpQkaKuLY//IcTkJ1sLfloD2RauMuci oFpl8vIkbKeS6/NuU+vfM4kDuSLQJDP2FqwIJHuOqFUGGsc+/sdggPyGuOdhr7TecYrP H2zhSrBh3M0nyMPVgkWY58brXqq4FpkYCPW5KTs9/ADS5SWqzoqzVaKNeQ+vem/jobWy sX4DbE1J5Q1iY4NlaqInCZiYNvWkioPRejf9AkreyEoHWAJkZ+yRlVuH31sT5UfbTdUK 6Tfw== X-Gm-Message-State: AOAM532X7mwWiyJql9jcc7+ZSh0AV+dtC6ANj/fHfETNhFSy/05kqKZ4 /E3LtCDdhdDJ0rSyUdkutHZm/T11JziI/sfD1km2r1KH4s3sn3y/YjPcoNAdJFdxOxi4XHhUc82 Y93f1EXrQ2940LclOoiN21WF/C9t/cdemHcoFbOgYicEjW7t+TdjJd4Alsec+jhhh5sU= X-Google-Smtp-Source: ABdhPJzeWaadYyAbNSlogHarg9JtLaTNwIfT+6tAacLJ4zRTGQ2v9ZyFr7z5bSt7ZJKGYgzoNQGzDPtleMRq1A== X-Received: from jeroendb.sea.corp.google.com ([2620:15c:100:202:6a19:24ee:a05:add5]) (user=jeroendb job=sendgmr) by 2002:a17:902:c401:b0:13e:f5f2:f852 with SMTP id k1-20020a170902c40100b0013ef5f2f852mr1546358plk.29.1633488146135; Tue, 05 Oct 2021 19:42:26 -0700 (PDT) Date: Tue, 5 Oct 2021 19:42:19 -0700 Message-Id: <20211006024221.1301628-1-jeroendb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH net v2 1/3] gve: Correct available tx qpl check From: Jeroen de Borst To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Catherine Sullivan , Jeroen de Borst Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Catherine Sullivan The qpl_map_size is rounded up to a multiple of sizeof(long), but the number of qpls doesn't have to be. Fixes: f5cedc84a30d2 ("gve: Add transmit and receive support") Signed-off-by: Catherine Sullivan Signed-off-by: Jeroen de Borst --- drivers/net/ethernet/google/gve/gve.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h index 1d3188e8e3b3..92dc18a4bcc4 100644 --- a/drivers/net/ethernet/google/gve/gve.h +++ b/drivers/net/ethernet/google/gve/gve.h @@ -780,7 +780,7 @@ struct gve_queue_page_list *gve_assign_rx_qpl(struct gve_priv *priv) gve_num_tx_qpls(priv)); /* we are out of rx qpls */ - if (id == priv->qpl_cfg.qpl_map_size) + if (id == gve_num_tx_qpls(priv) + gve_num_rx_qpls(priv)) return NULL; set_bit(id, priv->qpl_cfg.qpl_id_map); From patchwork Wed Oct 6 02:42:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeroen de Borst X-Patchwork-Id: 12538367 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7BBDC433EF for ; Wed, 6 Oct 2021 02:42:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8730611AE for ; Wed, 6 Oct 2021 02:42:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237297AbhJFCo3 (ORCPT ); Tue, 5 Oct 2021 22:44:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbhJFCoU (ORCPT ); Tue, 5 Oct 2021 22:44:20 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6324FC061749 for ; Tue, 5 Oct 2021 19:42:28 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id p2-20020a170902bd0200b0013da15f4ab0so672568pls.7 for ; Tue, 05 Oct 2021 19:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cj5zQAm/sTRoem/w0xkgTlleUfiHyH3CS2fRbDdBAX0=; b=GKAPtRn6oDMChc4QvFlATrelBKnDigFva4fzSFmgSOmuBoljp7yBGOW5+tDsV30WMT 1/xTjIQ+pDaCg8TYuCaGMLDVhiS07UapXrt/jPgvDdOHkQgVnPEhqzavhPoHSlIwkzE2 eJVMPal4fgepWRr3DQTAXK58GvdZ8pYKGwY9H4gRIgONHhyS3wVNLmXRVW5U3iNC/FzT ObGZF9/RbZVLvx7GGH+71NpsomFjcc43mPPQAcOe6kf1Ss3RLxG51TBqHVOKdODLxUyN XjPW40jNkuXfZ8giN1j2PK3Rau7MYD/7IXZyjAkPKXttQrBFFfXiHVHFkwUUMOGUoIHN Tt8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cj5zQAm/sTRoem/w0xkgTlleUfiHyH3CS2fRbDdBAX0=; b=iiU5PVEuknyjZ+EbbR7w7yCaOXKmUC2fUR5p4f4odGL/MpZMcFq3/JP1wC8GBVmles 0y95/2gmNfIJwd3dFzF8xA84UpgNpMfBieDKL4AF3z/lTYb8gIYBYAjiKbbnAMrNSByr mJnhT2zY9ZO3BEAQR+hiipJQobuvGFOaPeqCe+AN64a4D4z/7907zIl8QkiI2FJRSKqh goaabbdm2kwikbRCTjnmbZecPsFnXdqXH7GxSgdfW1CPt5zN+bOn2c9k9jfQwdk3hFvz WR2wm8Ho0vAgTlHhOkxqTSwOgHNrcEbZznm7nnfxZ9zQIkaEimc81y7oRwBDSHXuYVZd MJqw== X-Gm-Message-State: AOAM531+BuwJ38+iNK9cQtSgI5ORSljwDVL8YUbuH4wpxQLyc0D3zOOS +oTVJdNxac4MaWGiGFGUwNw4lwdgMcfsCUTEL6FMkP0mHw/ipMShvubR+tAFobXPePB3bh88vVR fcYIG9PBRxs5fDwlPvj23niCiAfbgtSwiGdHlNna2cu24+Kgto/1TC3oBkgNSgFHmTfg= X-Google-Smtp-Source: ABdhPJxOs2MoZd4gHAID+UzlmLPOfiQBnWJ/QuszsHZvMJoUzTgtI+KNFgpbuePhaRZKeumAgyZwuc0iCMHdKQ== X-Received: from jeroendb.sea.corp.google.com ([2620:15c:100:202:6a19:24ee:a05:add5]) (user=jeroendb job=sendgmr) by 2002:a05:6a00:1141:b0:440:3c27:807c with SMTP id b1-20020a056a00114100b004403c27807cmr33553423pfm.71.1633488147700; Tue, 05 Oct 2021 19:42:27 -0700 (PDT) Date: Tue, 5 Oct 2021 19:42:20 -0700 In-Reply-To: <20211006024221.1301628-1-jeroendb@google.com> Message-Id: <20211006024221.1301628-2-jeroendb@google.com> Mime-Version: 1.0 References: <20211006024221.1301628-1-jeroendb@google.com> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH net v2 2/3] gve: Avoid freeing NULL pointer From: Jeroen de Borst To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Tao Liu , Catherine Sully Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Tao Liu Prevent possible crashes when cleaning up after unsuccessful initializations. Fixes: 893ce44df5658 ("gve: Add basic driver framework for Compute Engine Virtual NIC") Signed-off-by: Tao Liu Signed-off-by: Catherine Sully --- drivers/net/ethernet/google/gve/gve_main.c | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c index 099a2bc5ae67..29c5f994f92e 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c @@ -82,6 +82,9 @@ static int gve_alloc_counter_array(struct gve_priv *priv) static void gve_free_counter_array(struct gve_priv *priv) { + if (!priv->counter_array) + return; + dma_free_coherent(&priv->pdev->dev, priv->num_event_counters * sizeof(*priv->counter_array), @@ -142,6 +145,9 @@ static int gve_alloc_stats_report(struct gve_priv *priv) static void gve_free_stats_report(struct gve_priv *priv) { + if (!priv->stats_report) + return; + del_timer_sync(&priv->stats_report_timer); dma_free_coherent(&priv->pdev->dev, priv->stats_report_len, priv->stats_report, priv->stats_report_bus); @@ -370,18 +376,19 @@ static void gve_free_notify_blocks(struct gve_priv *priv) { int i; - if (priv->msix_vectors) { - /* Free the irqs */ - for (i = 0; i < priv->num_ntfy_blks; i++) { - struct gve_notify_block *block = &priv->ntfy_blocks[i]; - int msix_idx = i; + if (!priv->msix_vectors) + return; - irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector, - NULL); - free_irq(priv->msix_vectors[msix_idx].vector, block); - } - free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv); + /* Free the irqs */ + for (i = 0; i < priv->num_ntfy_blks; i++) { + struct gve_notify_block *block = &priv->ntfy_blocks[i]; + int msix_idx = i; + + irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector, + NULL); + free_irq(priv->msix_vectors[msix_idx].vector, block); } + free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv); dma_free_coherent(&priv->pdev->dev, priv->num_ntfy_blks * sizeof(*priv->ntfy_blocks), priv->ntfy_blocks, priv->ntfy_block_bus); From patchwork Wed Oct 6 02:42:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeroen de Borst X-Patchwork-Id: 12538395 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A67C8C433EF for ; Wed, 6 Oct 2021 02:42:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85ABA611AE for ; Wed, 6 Oct 2021 02:42:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237308AbhJFCom (ORCPT ); Tue, 5 Oct 2021 22:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237292AbhJFCoW (ORCPT ); Tue, 5 Oct 2021 22:44:22 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 231AEC061749 for ; Tue, 5 Oct 2021 19:42:30 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id d10-20020a621d0a000000b0044ca56b97f5so251309pfd.2 for ; Tue, 05 Oct 2021 19:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=KHghRzm+vDwpKNdyfewWzgu1PA842NWtY3+BlaiG7a4=; b=cqkzvJNI9Ix6bhIhMqjh5zcxwbBDRfeXTl51q66U48L1z52CLFBVAk1MS+KEdEYYwK 5xOypGaAFW9Rqhn66IbPIqrJkY5Fl2SfS/65l7Dm80EkySR1EgM6s2qOHI6e/fMKpiKF 0ZDzXciVfFOQCUpeed2qQap4ITLyZIA9xe4miewG1YbQjXxAjBghjqKR5TMFRGtrG72f tuKvQz4ld1ddvIvX80MhxjK/f+uXrWwB5awbqrZ3ZdlbomDW3NlQCOVz1/PJZgzHLWAe 5/sM5xbGbQMJTYf06fgUbu1NlMHS4tyPuLPbUeHSgQtzNnMtmc79pd8wjG97Ro37/k9K eOaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KHghRzm+vDwpKNdyfewWzgu1PA842NWtY3+BlaiG7a4=; b=IlAwqLEazpBPya733Pl0KxYxM0DK5JlRdzA2rInZbBn24C072yipYoI2X6gaEp1EG1 MGj5hl+P0ZxEgF2fUePdRkxscRS9YZUk+QEHkjUQCpFesGSfBIHisOFvm7GYOSTYqGe3 Cj5aLVMtkt0/37i6m1CAIPw6iTusGWzKNHS61rn4B+P2bON/OxHrXcAxhA/bjzoDHNVj fjpMyf0tdj2tYdwPcvXpkT2HERrkchKC7p7hC5WHmpfYFLwsqCuOKLLMEIRE1chEIaWI hlc38YxwEWH/5jYDPU0WU281r7WkFMDx5H8ntYffOgqQSqXY3GH3ESsVOJdfyVx73yDc CKpQ== X-Gm-Message-State: AOAM532pmmfQ+z9N3qHq9oSr9XLYMLIHqPUyfmP68+gehSjLqyVA6M/U 697AeWM5lwTfcYdZhZ9XW6J7l7snSAik3eEsBIT9bt/5GUSjZBZxvLPE76y9DxmHTjai76Ir+oQ lALZOVpzVX1CuMkBStJxfhB57k0cu1S/7Pr9x0JNYoIZDWSvFLfGhIQKdh1WByxtwI2M= X-Google-Smtp-Source: ABdhPJxwtbq09l756Bh3R0fDXmjMfs4oWNAgYIwl36AVFP9/3WyDv25dp6Tbt6M8+HrSaCdFLMVe8+RNIAShsg== X-Received: from jeroendb.sea.corp.google.com ([2620:15c:100:202:6a19:24ee:a05:add5]) (user=jeroendb job=sendgmr) by 2002:a62:7bd5:0:b0:44c:72f5:5da4 with SMTP id w204-20020a627bd5000000b0044c72f55da4mr9992677pfc.48.1633488149400; Tue, 05 Oct 2021 19:42:29 -0700 (PDT) Date: Tue, 5 Oct 2021 19:42:21 -0700 In-Reply-To: <20211006024221.1301628-1-jeroendb@google.com> Message-Id: <20211006024221.1301628-3-jeroendb@google.com> Mime-Version: 1.0 References: <20211006024221.1301628-1-jeroendb@google.com> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH net v2 3/3] gve: Properly handle errors in gve_assign_qpl From: Jeroen de Borst To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Catherine Sullivan , Jeroen de Borst Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Catherine Sullivan Ignored errors would result in crash. Fixes: ede3fcf5ec67f ("gve: Add support for raw addressing to the rx path") Signed-off-by: Catherine Sullivan Signed-off-by: Jeroen de Borst --- drivers/net/ethernet/google/gve/gve_rx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/google/gve/gve_rx.c b/drivers/net/ethernet/google/gve/gve_rx.c index bb8261368250..94941d4e4744 100644 --- a/drivers/net/ethernet/google/gve/gve_rx.c +++ b/drivers/net/ethernet/google/gve/gve_rx.c @@ -104,8 +104,14 @@ static int gve_prefill_rx_pages(struct gve_rx_ring *rx) if (!rx->data.page_info) return -ENOMEM; - if (!rx->data.raw_addressing) + if (!rx->data.raw_addressing) { rx->data.qpl = gve_assign_rx_qpl(priv); + if (!rx->data.qpl) { + kvfree(rx->data.page_info); + rx->data.page_info = NULL; + return -ENOMEM; + } + } for (i = 0; i < slots; i++) { if (!rx->data.raw_addressing) { struct page *page = rx->data.qpl->pages[i];