Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp849086imm; Wed, 13 Jun 2018 09:12:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLl7x4YMNXDYuHlAds7D6Vh7AAq7Sgozn5NQN7fygbCaC7cUhAIyac/TOZp5ExHwZA72vjt X-Received: by 2002:a17:902:bd95:: with SMTP id q21-v6mr5761792pls.237.1528906333926; Wed, 13 Jun 2018 09:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528906333; cv=none; d=google.com; s=arc-20160816; b=vuS0ntzNT3EFFOIvKxA8o3y/J3MQT8IVU30mfZwHAwZYOCPOrG7GBJVgxjQyupYJLa paUtf5yyeYFz4dSrzDH7IYxpOXOVpZjVXZCT/dhGe05Nq6XeZWNZCluDHdTwchbA3962 iOdMHOjRdYr21PCQPlTP+1RQgUVILGDIIjisP79jzC+OqqpMkK/puJ8IIwJbYp13vMX6 oSvaBRqg3gVFbjPhO9GirazxlEUX/V82h3aHPavcOHzJ0+lbd75ezeD5wBu+cOjzzNVY ZK3oiKfq9zV3sMJvSfYkF/OfzI6QhOUuvbPL+m5j7csI1L3xEYJkko3+/QeKQAP8CDf/ tV4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=GM12LpGoVr5H+y54Udss05iEU1SzAQU4TatDCL4Jifo=; b=kxXqq2+BXYQFuIFYXXflc2beiCGKJ34cAiyyiyzSJodGGntF4PQJ4wZJKycpVnHnvu /lWMWv0OL2XAeBlGZbnuptIHvfIY7p2o8h3kFWa3PUQXvFWTICMRFs6X7FtdrQRnrZuC fLsiNqsJSlejqZx7/fXJcjkYZWujZZv11a2KlOQUE+KJph2G/sfne1CzbjQvK4XHBsQY /Zuh3YA6kgN6bra+NKhvFoIDAjdiQCvzEjSSHkjp9bFXxpnJxNRWf79LYRsO1HxFJ9e8 ZM0eCEfAUz9BR+oQdb7laB+edBkx2pB/ESrHbL354/Bh4GPj+3Y//nn0UG9+Oae0xDMS gpww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b83-v6si3350547pfk.342.2018.06.13.09.11.59; Wed, 13 Jun 2018 09:12:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935026AbeFMQKd (ORCPT + 99 others); Wed, 13 Jun 2018 12:10:33 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47668 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933498AbeFMQKb (ORCPT ); Wed, 13 Jun 2018 12:10:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8B794023334; Wed, 13 Jun 2018 16:10:30 +0000 (UTC) Received: from [10.10.122.249] (ovpn-122-249.rdu2.redhat.com [10.10.122.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5635C20284D6; Wed, 13 Jun 2018 16:10:30 +0000 (UTC) Subject: Re: [RESEND PATCH] target: fix potential memory leak in option parsing To: Chengguang Xu , nab@linux-iscsi.org References: <1528867646-138322-1-git-send-email-cgxu519@gmx.com> Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org From: Mike Christie Message-ID: <5B2141F5.5080102@redhat.com> Date: Wed, 13 Jun 2018 11:10:29 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1528867646-138322-1-git-send-email-cgxu519@gmx.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 13 Jun 2018 16:10:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 13 Jun 2018 16:10:30 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mchristi@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/13/2018 12:27 AM, Chengguang Xu wrote: > When specifying same string type option several times, > current option parsing will cause memory leak. Hence, > call kfree for previous one in this case. > > Signed-off-by: Chengguang Xu > --- > drivers/target/target_core_configfs.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c > index 5ccef7d..5512432 100644 > --- a/drivers/target/target_core_configfs.c > +++ b/drivers/target/target_core_configfs.c > @@ -1661,6 +1661,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item, > token = match_token(ptr, tokens, args); > switch (token) { > case Opt_initiator_fabric: > + kfree(i_fabric); You can probably just change this one and t_fabric so we do not even do a match_strdup since they are not used. Just let them hit the default in the switch so if apps are still passing them in then we maintain the same behavior from their perspective.