From patchwork Tue Oct 5 23:28: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: 12538171 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 CB628C433F5 for ; Tue, 5 Oct 2021 23:28:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A685A6109D for ; Tue, 5 Oct 2021 23:28:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237019AbhJEXai (ORCPT ); Tue, 5 Oct 2021 19:30:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236942AbhJEXah (ORCPT ); Tue, 5 Oct 2021 19:30:37 -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 0543BC061749 for ; Tue, 5 Oct 2021 16:28:46 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id z22-20020aa79596000000b0044c8c01b7a9so351078pfj.5 for ; Tue, 05 Oct 2021 16:28:46 -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=e3+IZmOWok86/4KWqVoACtEsKb2S0af+XuScec1C+TU=; b=lvjsGIKuGyq6Zp3iP/OUKDvOgXSevJrfB4djxzR+I6IARc1ClsFt7DJhyGKW2FzEGV 4p7XkENWDA97I5hcQyOhlTG9tSnUGiFqPsO7Kg3ML7zKEI2s0iLsK/cCkdJiJKHtCHTW /hcsDedhGGzQjIFTa7oA4QYnDvZ5hlJn5s7PwLusXngrSYkpUTy0cTHrjhVQpkreETSy Oq7ToEzR9fEeZNHy5yvlrWU1GBbT5j9UtERadkoaowm2fN+OARYk5gP4qydNxIS4jrUA qH0YK6aShNiVeyKwhKLrujdzrynEnCf/O7TFzsyOq3z1PSxkJt7Gn2fqAowr6xaLUvNc s6Og== 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=e3+IZmOWok86/4KWqVoACtEsKb2S0af+XuScec1C+TU=; b=iZZ5Rdtf4d+FKQKV7cANdUNEkgSIyTzf7n2OnSlFkwrRqECe9VS8Ccungv7B+6t02K IytGKHuVSeZomttfkDS9DNAHBV4nYEv0z5NEcwdscHPaNbGVmH+X4addrC9vCjf1arv4 CvZKRn3cZQ069oKhuRhVnnDmX8LpcqqlpKKn71bhaORNocpsG8WTcsQiUnKIIyYh2aFU phkbCQL6FvggxPfH3DS+wawDQpWUFxIG9TmmYoCTsJCflqntF/mdAf7MFFR8aOkpoahh RU8taqQL0jM3gfO8WkCmLTTn3gogqUQ+oSxNZ4GRJFVktkkLc55nf2rLXmcD5cc/Ls2Q i/lA== X-Gm-Message-State: AOAM533VPCKy3pmmilS2BZw/IXxCj4LCTiwya7aT/Y+ir5tdO16obOYR EF9tCy4Ht8LFgTJ7CZIx/jeQSlDiLPX5G2MGWngT6ZV5sAAg3N0vBeJmeYGWgPMC4M/g1SKi4UA jgrH8pghRAa9TJQXhw1/+WNVSD4WzK6t4pzKJ+wXiVR1efAzSfwnTrDme7SEAPRUEs5w= X-Google-Smtp-Source: ABdhPJySrDZLyMJfOw8NAEIFE/oPfrHbU7cgj8A9A/Oricz15BQj6qd8qcosRc60nK3leDFRI4tUASe9O8aYSg== X-Received: from jeroendb.sea.corp.google.com ([2620:15c:100:202:6a19:24ee:a05:add5]) (user=jeroendb job=sendgmr) by 2002:a17:90a:8b8d:: with SMTP id z13mr663873pjn.0.1633476525148; Tue, 05 Oct 2021 16:28:45 -0700 (PDT) Date: Tue, 5 Oct 2021 16:28:21 -0700 Message-Id: <20211005232823.1285684-1-jeroendb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH net 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 Tue Oct 5 23:28:22 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: 12538173 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 D6F62C433F5 for ; Tue, 5 Oct 2021 23:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7AF96109D for ; Tue, 5 Oct 2021 23:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237026AbhJEXas (ORCPT ); Tue, 5 Oct 2021 19:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236953AbhJEXar (ORCPT ); Tue, 5 Oct 2021 19:30:47 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E99A2C061749 for ; Tue, 5 Oct 2021 16:28:55 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id w11-20020a25ef4b000000b005b7151afcc4so815697ybm.22 for ; Tue, 05 Oct 2021 16:28:55 -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=ZkJlkYBRyN2l8fx9s8krQrLz+vZ/IsW0tc4DuRPVqEk=; b=MwNLSxHOLtWfxWPCCcrah6F7hmMAT4gkKQg6NFFfTkuSjQcTvgXMWNXmkcUT9tr/MA QhnHj2T8bd+txzEkDmk7D8cWIfzAUreJKoAJhKQnhvyEeNbMvUukf/U2k2THlZSO/01D wLtQNQgIfMzhR8Nl3xMR8lmIBlgNpPaAEXhufkxkFe96gQc0WGOPdNIi5j2kOJ2L84PD xUM8khXB5pgPtR48A9/pnjadcrMdGYi5HpLkwgNUazQZK/5d+bT7KOjuBOwwdrMiUR5u mzTA8zHnyIySHNlCjhF7ofT9jVhU0eaPviu5hGnBvfxg2EGYZ3eeUuuHtbpALNCIl54A YNqg== 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=ZkJlkYBRyN2l8fx9s8krQrLz+vZ/IsW0tc4DuRPVqEk=; b=ZABxsqrSs06QhaeOmhNZDs226xL+gN4tjjfbsUbArU6wxkKesB1WJGO3UV5I+Xe4eV ztB8f/65Hmr0McD1LioIK2lC0nY4IFfeuZs4KVZ3cTGEsW4uI05Rw7W1XDgbpYh6E7+z GztG0oShOa4296nD+5Rp4C6o5hnl7BgpNmWvbxW2SgBHDAx3IiTduFb0RC7CnlxpyAbz xyufJcDyxiGPmND7kiPD5/rXaveQXtr/QceMYGCCUpba81ov1EFgR6iYiPkz33v/69+z MYdlQ06lrI1yW2HujYGWRm8/DgBWNN45Q3voSNOgIIDJUj84vAmmxU1LY8tUeePdz/5E KgiA== X-Gm-Message-State: AOAM531SR89AiqI8X16KslszCxD/egQg3CSAXGnmm7fzAZIfJ5OhisQj Y6mRkxfU3hEWY1cw0D9X+F5H4wwUSQbXAAWJR6SpnS305gR5O67LVTFtD1jVHxo1LQekjX2k6Ve wrNpNMSLRZgH6DesGat+9GEpmWSHLXiwMC696sXQT31Fc8IRmZc67u43YRYkL6gKA32U= X-Google-Smtp-Source: ABdhPJxLn4zL4Nbb2akplrntsjUITvO2Lk0lWdHZZtdfs7INoDAGZZ/0EPHvfDGe8uJRTApuqXzxfBmCVgzbMg== X-Received: from jeroendb.sea.corp.google.com ([2620:15c:100:202:6a19:24ee:a05:add5]) (user=jeroendb job=sendgmr) by 2002:a25:5205:: with SMTP id g5mr24051514ybb.292.1633476535184; Tue, 05 Oct 2021 16:28:55 -0700 (PDT) Date: Tue, 5 Oct 2021 16:28:22 -0700 In-Reply-To: <20211005232823.1285684-1-jeroendb@google.com> Message-Id: <20211005232823.1285684-2-jeroendb@google.com> Mime-Version: 1.0 References: <20211005232823.1285684-1-jeroendb@google.com> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH net 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 Tue Oct 5 23:28:23 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: 12538175 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 9F8C1C433F5 for ; Tue, 5 Oct 2021 23:29:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83C296121F for ; Tue, 5 Oct 2021 23:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237036AbhJEXa7 (ORCPT ); Tue, 5 Oct 2021 19:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236873AbhJEXa5 (ORCPT ); Tue, 5 Oct 2021 19:30:57 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF161C061749 for ; Tue, 5 Oct 2021 16:29:06 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id j5-20020a170902c3c500b0013ebfb7f87cso434023plj.0 for ; Tue, 05 Oct 2021 16:29:06 -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=GwSHAgEnNcPVmt5R4/DzR39GbxNy7TwCC7f2tVXtjOA=; b=kD7PhOy6ETrZpDIPC3z3v9p27XuXHw7uQ/gLLq0o7dotZj3CWEthBZpc4o4aB3mu25 URNr0huVCiDg8XgA9RG603hyRhzF7wUoACIiP04ofMtYU8NlW+kWBqtQCHHBZ8/+9xSd nzSH57vayJo+XDyBtaAF0l9EKQ2KR1kMzX9LD+/PretiCEa3glfd8JJV1HGw31tf7ICq sG4BGJ0G/oCXda+rlT6KSgmJl8Vhsui+hWWzFq6i+DGfXny2fySaIihL4uTN2XY7WhYa WIfDDHG6Wlj0MeyYKMPpmozN8QTXvMUkHsxUsr13kkQxUGkrNqn8/UXQy9l3znOI3AxJ XJUg== 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=GwSHAgEnNcPVmt5R4/DzR39GbxNy7TwCC7f2tVXtjOA=; b=vvq+LiOaNGqKqohgaxjnsIqqTmRmMZCFbguI7ejyn+okJZm4G1oaQhkfZImOA0rRqM 4DrJppRUftSUa1oEvKrLpLuUalgXXD4fsRXfmwqssAxFbmFCK+HviQa4JRzzA8bUHsoj BUo6YkXt8dbwDjnZyrqloMmi1DRXdRsagBizoV0/jLvmLqk8W93hdaJvM7jp62kg+Kd0 s7ZuxfDJdGnH4ia7y3vOlLSrFY+qEwp4zshUeWzgJaVNMVn9IhNdP4a6xNNV+G3q8Ns/ ir+DoMFC+82X68wUK14OV4z1sMHtYGROdAroPg9QFDDRRP6hkcoZHyyyctrziOCSJUVb EouQ== X-Gm-Message-State: AOAM533fgyprTQPJb1n3OkGSHyYBsfbIjiyG8+gMDN2axxt6GH8zp/Qx ysEb08CAHTxpCp8ulML6p71n6QVjknddbehdzlX2apP6+10V0s2IpS6hjh0ewIoJapTBfZ/En5U N7N52HvWC6Q+nb2lzWcBPHKI+qfrQ4l9hnZ1pYUocPc1gsOtWLkn2VPTymJuzYHxVQTs= X-Google-Smtp-Source: ABdhPJwz8G7rOz3cELxyvpsKX1Pwww5CYH8Ct+RX7l/LvHrL0YijID8IMFQT6GR35wrz482bxCSRB8VafdhbEw== X-Received: from jeroendb.sea.corp.google.com ([2620:15c:100:202:6a19:24ee:a05:add5]) (user=jeroendb job=sendgmr) by 2002:aa7:9047:0:b0:44b:e142:8b0d with SMTP id n7-20020aa79047000000b0044be1428b0dmr18664635pfo.45.1633476546101; Tue, 05 Oct 2021 16:29:06 -0700 (PDT) Date: Tue, 5 Oct 2021 16:28:23 -0700 In-Reply-To: <20211005232823.1285684-1-jeroendb@google.com> Message-Id: <20211005232823.1285684-3-jeroendb@google.com> Mime-Version: 1.0 References: <20211005232823.1285684-1-jeroendb@google.com> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH net 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];