Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp900311rwb; Wed, 7 Dec 2022 06:24:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sb9hV7UdOCxRUhOARqcGcoLWGgdF/h4GdlLM/Jbt77Q+NzCR0+Cd1YTY1CQsX7Sf5YTl4 X-Received: by 2002:a17:906:6b93:b0:7c1:bb4:ea28 with SMTP id l19-20020a1709066b9300b007c10bb4ea28mr6010154ejr.64.1670423093458; Wed, 07 Dec 2022 06:24:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670423093; cv=none; d=google.com; s=arc-20160816; b=niFw12hN58I5vigjPtl5G7ox+kLvKVtSbhxqq9JSgOGkrXcz4+YzjaFUMcY8psdHny uo5nB3vyiG3BQ6f/GYbehaNkH8WA3hKDDTaAuSjD55BahKEvAsgWnNhFuoMXxCAKztTo twrboRJKXrxR+fkBnlNuhNudjo8bK3w73hFrWoTNnLGRznBHy25o4Lox1mCvp2xwt0Xy q/sZUW/D3495h6SF3OG5d+1Q/MMGH3n2NeWlmuzFzI6MNDBZWzCo8FN4A8f5cjoxGJMg 4ZmUfPig5BCCF2P0JV/xHNyhDVz2uS2lMNNvHOYRTA2gzmtFtBmN0lwOuhUU95ZPlV9Z MSsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mtuzOfw0Oi0U8E5fGsLC9amop5MnEpGVuaEzshiOd2A=; b=swLQrbrJZ02gZu40lYW90/6JxxaBb0wo4gTn+c5uapho9wyFYdwuPnK0oivhZiH9GU 2cqh/6kZHX9gpXFzB5lMZ6NFHt6yY68G8tn4XSaaFGMAPafCmDAB6PL+19CKTczW5Fbh s8ENI+uejiHDF7dLEZmMrjd0aEdmKQ7Je248VZjTOZEJhkdG1MKpaIHFZ0FiK9F7/tog FLpEMan+SVyM0IqpQA1XvzANDfNG4bdpZ5h1vE0PFJs23zed++iJ8bc0rb5uZNu92Ssn mmLA0fmJ+Fvr0cUhQusRHmcCdcBhEKqJje35vfYo5uRVQihPZJg36YQhaqcxHwq5u7Gk o0zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20210112.gappssmtp.com header.s=20210112 header.b=MoXad6PO; 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 dt3-20020a170907728300b00782539a0286si4140616ejc.142.2022.12.07.06.24.34; Wed, 07 Dec 2022 06:24:53 -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; dkim=pass header.i=@resnulli-us.20210112.gappssmtp.com header.s=20210112 header.b=MoXad6PO; 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 S229507AbiLGNlY (ORCPT + 75 others); Wed, 7 Dec 2022 08:41:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiLGNlT (ORCPT ); Wed, 7 Dec 2022 08:41:19 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6061C59176 for ; Wed, 7 Dec 2022 05:41:17 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id kw15so10627015ejc.10 for ; Wed, 07 Dec 2022 05:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mtuzOfw0Oi0U8E5fGsLC9amop5MnEpGVuaEzshiOd2A=; b=MoXad6POrKxM+1W1tpTYK0V/OAfkJ8/5ZfglWKfn4OVK/dpJoQLI30qKWoExXjVwk9 TrtW4BntvSL0vTXRWLgwSKj1aue+B6dTv5RSUqJC5REBoEkHXPuzGUzEm4A/ELWfaC4j 82d0N+kvsP0Y+Dex9cozH/7hs8zcFLpJWihpWHZqTtQx9RapuP2cVBnEwlNbeSY17aqe vNKK7Jn/7HNKVBZ+own0ke+EPRJ0b2Mo4yur7rVyW/PAsjCBNT/mOi7Kss0B4D/dYlnH m9opYgalLf8pL6RjStNmYJITFDDRuG8BBf++X4UTY6OpI1IFjyKok3eA69fDsYuKsKIi WOIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mtuzOfw0Oi0U8E5fGsLC9amop5MnEpGVuaEzshiOd2A=; b=TlNYKg0lnc7n4ihIN7eWFftVoiBF8z0r1ySTsVmdaH8FAgdDmkgaPyG4s3krUxP99k 99SsWhraxtjZb+81JHmYrVfVm5L0T1mblSotSvcoxozui7USjHL3fu8tvVU3oGL4hAVq SLPQF0vY4JG+4UKwYjfpP90BaWlWWsSgZw7yYtqH4dKy8dtNHRdGI17/ao+xfzzHvPYS oAy5N1CN4tve6BeCDAgdFuPOW8fI4GQVkDIB5xwFS2GMdYUdUA+9j3TXkAU0jGvz44o+ cb/uqseoEURUqLACUxUyGNWb8cBcGrCWWK4OToDUAxjTPcnxuoBxw70fBZyxlDIqR4J/ nDfQ== X-Gm-Message-State: ANoB5plrhw/YNrxN4yzlu/cZADkuZBtT37CQ4xxJbTki00pb/UpNaYiU IeCwevjBn3Dy8uCaH7GtabxcOyIvy5b6cAXgC3w= X-Received: by 2002:a17:906:a209:b0:78e:ebf:2722 with SMTP id r9-20020a170906a20900b0078e0ebf2722mr73484504ejy.490.1670420475980; Wed, 07 Dec 2022 05:41:15 -0800 (PST) Received: from localhost (host-213-179-129-39.customer.m-online.net. [213.179.129.39]) by smtp.gmail.com with ESMTPSA id 1-20020a170906200100b007bc3a621224sm8561495ejo.196.2022.12.07.05.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 05:41:15 -0800 (PST) Date: Wed, 7 Dec 2022 14:41:14 +0100 From: Jiri Pirko To: Jiasheng Jiang 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 Subject: Re: [PATCH net] ice: Add check for kzalloc Message-ID: References: <20221207022000.44043-1-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221207022000.44043-1-jiasheng@iscas.ac.cn> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Wed, Dec 07, 2022 at 03:20:00AM CET, jiasheng@iscas.ac.cn wrote: >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. It is not about details, it is about "imperative mood". > >>>@@ -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? You are right. > >Thanks, >Jiang >