Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1065348rdh; Mon, 25 Sep 2023 02:02:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH31YwWkVo9nI/TBl47fn4p6Nh73SVCV7e3hjOBO52hGWqrOTNejvOQSyqiHejNElgkVpUC X-Received: by 2002:a05:6870:7024:b0:1dc:c65e:ded2 with SMTP id u36-20020a056870702400b001dcc65eded2mr7917545oae.12.1695632576094; Mon, 25 Sep 2023 02:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695632575; cv=none; d=google.com; s=arc-20160816; b=M9jajOYf7RYMRMZtr0ItjSuNPNRBnDCoiOuhh5n6fzQ3ZzVRZFAWkHCj+M0pfOOslx tbGDWfkeMd7SpmWdDZ196Tv/+T54lhqFwa/ksyk5JxtcWz1ybMYM3eTncJNXAH6OzxTc gDY8hPGmWt8ZhVKkVGPAeGA7qrZjJD8XGHOpBE9C3+xQlgjXG5+WMJ4nwWaVmEv5sfaF R/qZngG7NaHjDgT5rs2g4FwPZlzSJktduvLL01Sy57rMJQx8+H9WhDM/C2kAYdg7JwhM dBfBRBFlIYbEt/5nwfNowIKZ61OuwmAHhKVOWKKwT27CGWaV2NmGAKxSmrgACUveXQar vnkQ== 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; bh=OjCavDNCrzyV0AnG6IR/QqNBm54l1YV9edfkGf6ZEMo=; fh=zE61ijPVwzc0QbIBWMfKA4wRKU7ZbbMygv+SZFkZjrE=; b=fOkBWUkM2MX9WfWLmrJHV8Q4uwdKSMGCar7jSsoxiDiVO+Kfz7D5DeGb7D9m6bcah8 FP4l+b6crVMLux7gTm04HHuGTrSUY7Ls2fiUT90mRTczwEaraEvfzAX+jHiuyKtSoK5y GL9i57xLBjd9wAec3I788XEIeYPfp4AoDN+84I3Q7Nh5GPDecgCbtOy6xMjAYwokB6Lp XSYcRn57NytSLTETq3eYosTVhKGqizCDZVYRRIKcVUrsnfHY6NKEN3YBiZHV1rdX6vY4 TqZMOTPKrb/Ebj+eTOZ3hZSCpq/iiFpwKyc2T5/rTelVlQWsVjgmGsFazhLuDP7cKGUx r7tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id bz14-20020a056a02060e00b00578e7a37c44si11249208pgb.42.2023.09.25.02.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 02:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5672080781F7; Mon, 25 Sep 2023 01:55:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233086AbjIYIzq (ORCPT + 99 others); Mon, 25 Sep 2023 04:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233081AbjIYIzp (ORCPT ); Mon, 25 Sep 2023 04:55:45 -0400 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 371A9C0 for ; Mon, 25 Sep 2023 01:55:37 -0700 (PDT) Received: from localhost (unknown [124.16.138.129]) by APP-01 (Coremail) with SMTP id qwCowAC3vfV1ShFlTKihAw--.8010S2; Mon, 25 Sep 2023 16:53:09 +0800 (CST) From: Chen Ni To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, nichen@iscas.ac.cn, izumi.taku@jp.fujitsu.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fjes: Add missing check for vzalloc Date: Mon, 25 Sep 2023 08:53:18 +0000 Message-Id: <20230925085318.1228225-1-nichen@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: qwCowAC3vfV1ShFlTKihAw--.8010S2 X-Coremail-Antispam: 1UD129KBjvdXoWrKryDWr4Utr43tw45uFW3KFg_yoW3Krg_ur 4IqF13u34j9r1qyr4DArW3Zryjvryvvr1IqwnaqrWaqrWkCan7A34xuwsrX3yUGay3ZFnr Jr9rtr13A34fJjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb2kFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVAFwVW8ZwCF 04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r 18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vI r41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr 1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvE x4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUjNJ55UUUUU== X-Originating-IP: [124.16.138.129] X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 01:55:48 -0700 (PDT) Because of the potential failure of the vzalloc(), the hw->hw_info.trace could be NULL. Therefore, we need to check it and return -ENOMEM in order to transfer the error. Fixes: b6ba737d0b29 ("fjes: ethtool -w and -W support for fjes driver") Signed-off-by: Chen Ni --- drivers/net/fjes/fjes_hw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/fjes/fjes_hw.c b/drivers/net/fjes/fjes_hw.c index 704e949484d0..3a06a3cf021d 100644 --- a/drivers/net/fjes/fjes_hw.c +++ b/drivers/net/fjes/fjes_hw.c @@ -330,6 +330,9 @@ int fjes_hw_init(struct fjes_hw *hw) ret = fjes_hw_setup(hw); hw->hw_info.trace = vzalloc(FJES_DEBUG_BUFFER_SIZE); + if (!hw->hw_info.trace) + return -ENOMEM; + hw->hw_info.trace_size = FJES_DEBUG_BUFFER_SIZE; return ret; -- 2.25.1