Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6308304rdb; Mon, 1 Jan 2024 18:20:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcBrnrXRnXEICgx2BuaVVJRyvEuRNjNvmAvhnFwjYfu8aqP58zN8TDfxuBhLGElgZiDq7X X-Received: by 2002:a05:6870:1616:b0:203:f739:ca8f with SMTP id b22-20020a056870161600b00203f739ca8fmr13480264oae.36.1704162015284; Mon, 01 Jan 2024 18:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704162015; cv=none; d=google.com; s=arc-20160816; b=NzlHE1YL8bN3NXH/aZqlI24u+1qzIctRQwGvCBINnwJgtm1FAKQOBeC9FHyD9X9A5/ alaWdzNcpg0OwCpP8nESq8VghSkFwfzBnchpBnFObyytYBGiZ6aarU2aSL73QcMxsTYX IiGfOAFGCAJWqpwMn91TIYRDv4QrUhmXM+vhiZtHVVJh9BNTHnUg/eUJdOTs7Ll+D6ON O2nx0Q3VzI5ZKPs+Xh3Svdu0tVca/umQ2FuOP9NOSRK1RIwrOQxxRH6k1QEPmIonGXH2 s7ZHv+4gxwotlCo/0EMW6OmDXxw0ErQSfy3co2+fhQx6VSOkBlIipNxEF3FSVPt3IZ6A gxyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date; bh=dCDORE9qUTwiAxZ/9HQqD3OX/FpBsQxPu25hDmf5Gjg=; fh=ZpVz65prVw/TNRwAfASLLBy5mMlUdQ8zEJ9wRoQjyBA=; b=uS1DRIhrIvG93LekdaflwmCIhkEsqkttJKDZEDrZ0wWutlAMfLYiG3zMfFwq5t1NhM RJanbDcPTtkZ6UKWG9ALGrz8mIjlAQe9ffpeWusCZhDIklMhEi5yDPC0zYxRuOv0tex+ P22fM04SBrD7VGCZ8HgdW6hqUHdwqHWcaXKDGf1QpZ+O+6aNkrzpUkucYilK9kBtkfqV GYKWmpRzYMcnzYUJW/qeLBIbCuuoRvexRyEzaGxLa9Qpmy2fI9Fak18Iqiodm/hQg1Ga XBxCaQsWDDmF/pJOY6zALW0hCTMAcZqE0IbS5Z0V1IYflPoRscR3WtNAWDYsh5nJkbfu HaUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x31-20020a63171f000000b00585a5e9a965si19339769pgl.161.2024.01.01.18.20.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 18:20:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BE875B21353 for ; Tue, 2 Jan 2024 02:20:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C2D410EC; Tue, 2 Jan 2024 02:19:55 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CFD4A38; Tue, 2 Jan 2024 02:19:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=tonylu@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0Vzj5iao_1704161982; Received: from localhost(mailfrom:tonylu@linux.alibaba.com fp:SMTPD_---0Vzj5iao_1704161982) by smtp.aliyun-inc.com; Tue, 02 Jan 2024 10:19:43 +0800 Date: Tue, 2 Jan 2024 10:19:41 +0800 From: Tony Lu To: Markus Elfring Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, "David S. Miller" , "D. Wythe" , Eric Dumazet , Jakub Kicinski , Jan Karcher , Paolo Abeni , Wen Gu , Wenjia Zhang , LKML Subject: Re: [PATCH 2/2] net/smc: Improve exception handling in smc_llc_cli_add_link_invite() Message-ID: Reply-To: Tony Lu References: <8ba404fd-7f41-44a9-9869-84f3af18fb46@web.de> <5253e660-6b66-4775-ae2f-06f5a1d40be5@web.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5253e660-6b66-4775-ae2f-06f5a1d40be5@web.de> On Sun, Dec 31, 2023 at 04:00:22PM +0100, Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 31 Dec 2023 15:42:07 +0100 > > The kfree() function was called in some cases by > the smc_llc_cli_add_link_invite() function during error handling > even if the passed variable contained a null pointer. > This issue was detected by using the Coccinelle software. > > * Thus use another label. > > * Merge two if statements. > > * Omit an initialisation (for the variable "ini") > which became unnecessary with this refactoring. > > Signed-off-by: Markus Elfring Thank you, LGTM. Also net and Fixes tags are needed. Reviewed-by: Tony Lu > --- > net/smc/smc_llc.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c > index 018ce8133b02..2ff24a7feb26 100644 > --- a/net/smc/smc_llc.c > +++ b/net/smc/smc_llc.c > @@ -1163,23 +1163,21 @@ static void smc_llc_cli_add_link_invite(struct smc_link *link, > struct smc_llc_qentry *qentry) > { > struct smc_link_group *lgr = smc_get_lgr(link); > - struct smc_init_info *ini = NULL; > + struct smc_init_info *ini; > > if (lgr->smc_version == SMC_V2) { > smc_llc_send_request_add_link(link); > - goto out; > + goto free_qentry; > } > > if (lgr->type == SMC_LGR_SYMMETRIC || > - lgr->type == SMC_LGR_ASYMMETRIC_PEER) > - goto out; > - > - if (lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1) > - goto out; > + lgr->type == SMC_LGR_ASYMMETRIC_PEER || > + lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1) > + goto free_qentry; > > ini = kzalloc(sizeof(*ini), GFP_KERNEL); > if (!ini) > - goto out; > + goto free_qentry; > > ini->vlan_id = lgr->vlan_id; > smc_pnet_find_alt_roce(lgr, ini, link->smcibdev); > @@ -1190,6 +1188,7 @@ static void smc_llc_cli_add_link_invite(struct smc_link *link, > ini->ib_gid, NULL, SMC_LLC_REQ); > out: > kfree(ini); > +free_qentry: > kfree(qentry); > } > > -- > 2.43.0