Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp237518rwb; Tue, 4 Oct 2022 03:23:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62PQwLnyq0BGDoXapHEkCT0Eb7p7UyI/X4dxIvoYqW2Utyd6qOX/23MRpbhPmwJQ5ksb3c X-Received: by 2002:a17:90b:4acf:b0:205:eef7:7716 with SMTP id mh15-20020a17090b4acf00b00205eef77716mr16407332pjb.19.1664879030150; Tue, 04 Oct 2022 03:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664879030; cv=none; d=google.com; s=arc-20160816; b=S33WF4z5TLEpjCD26U53vv9qCM90ecEKdc7+2A01MizjdIqBJ3q8FVtRHeDjW24NCQ nMXNglaEM1WdFSwIHD62bLEvL2thilMfOQtfxHf4N9Y7mChLUEGu4R+CiXrqRYzDWk+T cIXr3+lPnSk/16JBKSDUv+Bk+IA7tO4KMZ2FXVXd6uGb+djrNP4+xSERa6//mLBW8K8w DzQ6NQqE8DK3LkE3RlWQTSfBnZkct7ZS2jKypc6mQuUtF55EfUprK1O2hB25n/BlswCj wkjRd9deCVd0AcYh+aEsL10w1dXTahbUrPCzSIYWixco0Y4UfC0FWbpgesFu3Q1EUrIu Mzqw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=QT4ZZD5QCiKRCcx0/Pk1b3npVhtS9LHTVZjmvhrqX78=; b=q45R90kmdWSwY+H7Y8I24OfkR97IQt6mJTa82u+N4XuajeS2UPJvdVi88UAsgS58p9 6rkr4MFNGGNlDDSWjyd8ypUvKryk1GA8wWQboIDpfciarkkAquTJ/kG5VtwFeSwTyLIV 9bWYFE4+O/JaxnKSl3T+nvDawgR236rlGvUtbzdi2/EeEawoTULQf+rB8cs8Ib1VXb95 /zKsUgpQnbzMNcEvo++DxBfAp9Pqnen6udwJm6IYpt/zQ8IzQm2PrTztz8epZs6DDRLH 8bWgLFFmiFvLbUGJNznuNP7GyP3cfCpVbsqM9pt77DyGLt1m2RiB5ouOtEc70fE683/R ATSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LGloIE8h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 22-20020a631756000000b00448c6dd8fa9si9094354pgx.444.2022.10.04.03.23.38; Tue, 04 Oct 2022 03:23:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LGloIE8h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbiJDKM0 (ORCPT + 99 others); Tue, 4 Oct 2022 06:12:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiJDKMY (ORCPT ); Tue, 4 Oct 2022 06:12:24 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9AC28711; Tue, 4 Oct 2022 03:12:23 -0700 (PDT) Received: from lenovo.Home (unknown [39.45.148.204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id 713DC6601A43; Tue, 4 Oct 2022 11:12:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664878342; bh=i0FOyOJitjB3rivlOUVsPgHHrU9fXSmrQW1VoDwnAqk=; h=From:To:Cc:Subject:Date:From; b=LGloIE8hXSiui08//z5wEic2e+LZAD8ZPaHHFGl6eL4NpDKnSc2Ce0vKDoJ8ko6QP yI+SXxdH9JGKcWbunxKhdBonWb9nf2oE3XmmCbl1K8EJU/v6JNyVsQFgTJk//jafLf vRsYOpTvivWUNIS0nhD4XInIZynwBBeTXa8jV/7zzcr+MCsQTnTtQ1jMLWujkq5FZY D6IAIFoUhNADowuBLyNdyjHqASBzg9q4W2H74Y4B28TlJ4ZclAiwHmrGBxVrbAaOI7 99bGMV6OgaRdx5019SZw7hC7sFSmIO+cqI0pfczgEv5kyqOQHBOHFy0Z2t1qqFJJIx 0TOM37dCXltRg== From: Muhammad Usama Anjum To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Long Li , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jason Gunthorpe , Ajay Sharma Cc: Muhammad Usama Anjum , kernel@collabora.com, kernel-janitors@vger.kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: mana: store return status in signed variable Date: Tue, 4 Oct 2022 15:11:57 +0500 Message-Id: <20221004101200.758009-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 The mana_adev_idx_alloc() can return negative value. Save its return value in ret which is signed variable and check if it is correct value. Fixes: ee928282bfa7 ("net: mana: Add support for auxiliary device") Signed-off-by: Muhammad Usama Anjum --- drivers/net/ethernet/microsoft/mana/mana_en.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 7ca313c7b7b3..1c59502d34b5 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -2203,11 +2203,10 @@ static int add_adev(struct gdma_dev *gd) return -ENOMEM; adev = &madev->adev; - adev->id = mana_adev_idx_alloc(); - if (adev->id < 0) { - ret = adev->id; + ret = mana_adev_idx_alloc(); + if (ret < 0) goto idx_fail; - } + adev->id = ret; adev->name = "rdma"; adev->dev.parent = gd->gdma_context->dev; -- 2.30.2