Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp156854rwb; Tue, 6 Dec 2022 18:52:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf67hulGatG4f+l7R+1bt7gPBtrkx0hDkIxPIZCxJ3Z4Vr//itqbNKeBqWVkQ9cn8co3Doua X-Received: by 2002:a17:906:180e:b0:7a2:6d38:1085 with SMTP id v14-20020a170906180e00b007a26d381085mr59053664eje.114.1670381531904; Tue, 06 Dec 2022 18:52:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670381531; cv=none; d=google.com; s=arc-20160816; b=OIdgl0swfR4+7FJ7DugR2xZbBfctXnB/klaCE4sM2llDreF24qFnThNx0z0+Tg5htD YtPoBiaQUZRr0bMT2IMOZhNivHgInG2QRsPw1d/nGiJOP0WBOn1GXrPmzrAwHb7Ux2aJ V9QXSgjvW54qFdBiv6jLBDzI8DgkGXyJFiarI43popGkSm+JP4xDvjA6CdzU+7oaoJkV tTI+yPbtUA7nzqfoyrKZkcRAZYR0tVpNoZsg9xWMnh9viPzaK6nkUBltWd3G29B/GFZS gqDhTQrr58U0yPk351GFNJ736LkfkEogxMAZ+hxv0Jw6l0TouMBvkdiOmw3VolpCxFPt 8rQA== 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=IIjdfvxoI3WILH125pqR5rFxEu3pczMtDEO46uj6HUQ=; b=rW2ONs9HYjHkEycaZjtsjzZzz9gfpi1wHicmY0zt74735G/5zN5xerkbyRk5RC+0Ff ur4MNAKHE2qK2IRxJzBa6Fd+6C8kyQcTdESqDnlKoBgZsSEUTv90docbQA7lMxqjGoWK VJsVTnDL1sG6N0lnUbmwL2ToxohYchVvoxVkFUohdBzHNI/Hnx04rtnTHUf2k9px8yyg x2nA1dkv30oP+wEf/ZlPHSLsZddV/2k2Y27tVOpH3qJVayOwK0WTuJhRR6QvYBAXBY7u OQl4eIX+27r/kdo66ab+NRN60P0S86Q59RrrjAmih3IqgVmEaWHdBrCsVSWDgU6uwJT1 mBeg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du7-20020a17090772c700b007919fc02ce8si3991669ejc.971.2022.12.06.18.51.53; Tue, 06 Dec 2022 18:52:11 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229480AbiLGCUr (ORCPT + 77 others); Tue, 6 Dec 2022 21:20:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbiLGCU0 (ORCPT ); Tue, 6 Dec 2022 21:20:26 -0500 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6B7DD4E432; Tue, 6 Dec 2022 18:20:24 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-05 (Coremail) with SMTP id zQCowADX+M1S+I9j2FxvBQ--.64308S2; Wed, 07 Dec 2022 10:20:03 +0800 (CST) From: Jiasheng Jiang To: jiri@resnulli.us Cc: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: Re: [PATCH net] ice: Add check for kzalloc Date: Wed, 7 Dec 2022 10:20:00 +0800 Message-Id: <20221207022000.44043-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowADX+M1S+I9j2FxvBQ--.64308S2 X-Coremail-Antispam: 1UD129KBjvdXoWruF13tr17Jw1UKFy8Gr1DAwb_yoWDurcEkF yDZrn7X3W7Jr1xZ3WayrnrWFn3urW8ZFyIga4Yqr4ay34DJrZIyFnFqry3A3yIgF409Fnx JryDAa4Y9rnxujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr 0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E 8cxan2IY04v7MxkIecxEwVAFwVW8JwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF 0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x0JUDDGOUUUUU= X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 On Tue, Dec 06, 2022 at 05:47:01PM +0800, Jiri Pirko wrote: >>As kzalloc may fail and return NULL pointer, >>it should be better to check the return value >>in order to avoid the NULL pointer dereference. > > Okay, so? Be imperative to the code base, tell it what to do in your > patch description. OK, I will describe the changes by the patch in more details. >>@@ -462,6 +462,17 @@ static struct tty_driver *ice_gnss_create_tty_driver(struct ice_pf *pf) >> GFP_KERNEL); >> pf->gnss_serial[i] = NULL; >> >>+ if (!pf->gnss_tty_port[i]) { >>+ for (j = 0; j < i; j++) { >>+ tty_port_destroy(pf->gnss_tty_port[j]); > > You are destroying port which you didn't call (pf->gnss_tty_port[i]) > for. Also, you are introducing a code duplication here with the error > path couple of lines below. Please convert this to goto-label error > path so the cleanup code is shared. I will convert this to goto-label in v2. But I have a question that the j is from 0 to (i - 1), and therefore only the initialized port will be destroyed. Is there any wrong? Thanks, Jiang