Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp120276ybg; Mon, 8 Jun 2020 18:10:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnXdp/0vPVu08RYJlDEujtqQuIEQP1v8bKZcHuuRZdMrD18opJRiq4g7tOMtypLV300zf+ X-Received: by 2002:a17:906:4f13:: with SMTP id t19mr14698932eju.269.1591665035744; Mon, 08 Jun 2020 18:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591665035; cv=none; d=google.com; s=arc-20160816; b=KlfNYArS9GtiFYUkrYWav9Rs+pFF81qsoYokQAudVo83kx/nNEHD3c9SMQ2Jr/GHy3 tse39VxRBogE3+HIIKler6TAw3HxjzrosRdhcoPVdXvWD0k7fXH7BHNQznAo456bfeUL UIMhy/Hq5lfrS89gzjM8SBKt7B59DngrAKUl2sGWXQcp31Ugm/GIkq/32GVGBiSeQ7Hb bv7JeMUxymV4pX4Di2nn6eonNV0EOgohJ9zcJ+87jkCmSyFik1ezJasi+l0C93K0DZCq gYLREPagHfsU7kGBw4K3xTHs4F6HW64Lbz0pLP7JPpd1kBNZK7MT5uuqrSoIQ492F/gQ 9oCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=35UUwV0C0Dfu4ZcxcMBCE52p7E/8/VGM2lxVbtTmcPs=; b=uGt6yEJcnBYvSOr1GqZFViVW0FSNAE14CxvQBUKDEiP9MBaqSXkKnFzNSooNE1dMyq uhVOJKVyhEJkmnXyguwfbjOFFfQiHvpC1apbkvyblZcsOQOmpkiz4PFIDdlfpbcCcIvH j3BLAO4J9J2VfPPcISRRmjj6QwbsTAiafJiDqXKKPiAJ3YbmToBJc9wx3e0CorRSlt1U QnbxpYXJoA+60dxyVwQP4o/sncUuglmTeQinoCF1wEiHlx/KZSmQkKtMO5aeH7MsDo83 /yKWLpYnobNVo7fwtJdREcsGjfKJh+yxlxntMaNLPRA++ASpvExCAAhfJgBZT9C4qJhG PpGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EuSjLWLK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs16si3151983edb.197.2020.06.08.18.10.12; Mon, 08 Jun 2020 18:10:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EuSjLWLK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730881AbgFIBIb (ORCPT + 99 others); Mon, 8 Jun 2020 21:08:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:50126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727063AbgFHXGo (ORCPT ); Mon, 8 Jun 2020 19:06:44 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3663F20774; Mon, 8 Jun 2020 23:06:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657604; bh=uyTL2Lu6aIQbzbN9xNngetGgXUNcmBdT+z3cenf8g70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EuSjLWLKVDSST8YnBGzmK/lQbjKo0zTzoeGxpj7uBtzTDbNAMuLnhjWV6vq7wdTx0 hBRsL/mb0yRK9BVXpMcooKDIR5Zk5rrfVowqSAgvnc5CTAM3XDB9Dxdsm7oi7bXMzz oLXGODs3BVkVkgaY8Fu9vmtY8E5UIXhluEq1HScQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arthur Kiyanovski , Sameeh Jubran , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 029/274] net: ena: fix error returning in ena_com_get_hash_function() Date: Mon, 8 Jun 2020 19:02:02 -0400 Message-Id: <20200608230607.3361041-29-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 a250046b8e18..07b0f396d3c2 100644 --- a/drivers/net/ethernet/amazon/ena/ena_com.c +++ b/drivers/net/ethernet/amazon/ena/ena_com.c @@ -2345,6 +2345,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, @@ -2357,8 +2360,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