From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5AA0C433E1 for ; Fri, 19 Jun 2020 16:26:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8963B21707 for ; Fri, 19 Jun 2020 16:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592583963; bh=8VsisCMdQB7FOqcUK+LQADDqxVzfGHy233uyzs+RPE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dDRIdgW++ZW9kGvMpt5O4c/crxM0RGszprpkwPJOAwa3GgugkK1OOGyQQSjxm2ZH1 A3lcuu/Z6oSk+jxSXYFu5X7alSCLqRrR+Xd/GhEHd1LFSGeqIj0XxZZW3vkSOeV1Fd 0Qk9c+Nh7Kz9R2dicrUMsS/Ju8m9xAc31xWL/jVE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394734AbgFSQZz (ORCPT ); Fri, 19 Jun 2020 12:25:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:52680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390226AbgFSO5U (ORCPT ); Fri, 19 Jun 2020 10:57:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D2AC217D8; Fri, 19 Jun 2020 14:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578640; bh=8VsisCMdQB7FOqcUK+LQADDqxVzfGHy233uyzs+RPE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9dlgHhcKqFZOUE+K8mL7ve/7HtdP88UVDZoTVUnjhHTSyTkRXcq9N2LCC4ZPCCJy IX2FHgJHw9NyP1shS8rai79EGGph4ryIbcLu7uAqV1rbZ2RL3bKYHxcsy1kNeksPL0 PG+pWeSffG2Ojnmh9qCsuTfdlG2gUGIBB3EkJ68k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sameeh Jubran , Arthur Kiyanovski , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 100/267] net: ena: fix error returning in ena_com_get_hash_function() Date: Fri, 19 Jun 2020 16:31:25 +0200 Message-Id: <20200619141653.669694587@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arthur Kiyanovski [ Upstream commit e9a1de378dd46375f9abfd8de1e6f59ee114a793 ] In case the "func" parameter is NULL we now return "-EINVAL". This shouldn't happen in general, but when it does happen, this is the proper way to handle it. We also check func for NULL in the beginning of the function, as there is no reason to do all the work and realize in the end of the function it was useless. Signed-off-by: Sameeh Jubran Signed-off-by: Arthur Kiyanovski Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/amazon/ena/ena_com.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c index 3afc0e59a2bd..d07f7f65169a 100644 --- a/drivers/net/ethernet/amazon/ena/ena_com.c +++ b/drivers/net/ethernet/amazon/ena/ena_com.c @@ -2137,6 +2137,9 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev, rss->hash_key; int rc; + if (unlikely(!func)) + return -EINVAL; + rc = ena_com_get_feature_ex(ena_dev, &get_resp, ENA_ADMIN_RSS_HASH_FUNCTION, rss->hash_key_dma_addr, @@ -2149,8 +2152,7 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev, if (rss->hash_func) rss->hash_func--; - if (func) - *func = rss->hash_func; + *func = rss->hash_func; if (key) memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2); -- 2.25.1