Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4512134imu; Sat, 19 Jan 2019 11:08:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN4qnhBmZ6SKTefAfAwbn/bWAtqhBWaD74c6EO5Bn5vL8QuLpUS0nO2tfyhsPideaUhRedw0 X-Received: by 2002:a63:104d:: with SMTP id 13mr22514985pgq.303.1547924888314; Sat, 19 Jan 2019 11:08:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547924888; cv=none; d=google.com; s=arc-20160816; b=jbjeRiDMuuHK8kbyZz0RHFBVpRI7IOVJJiWqE5CswNFBbemFIoi/+NOs1HWoG2vvDF 3xuYMtpsGYRzdBSwU23JytiH7pHcTYdDZzxc1DhU5WrxrFTrK4+7cpyY8FZ9ehR/ribg OoiYELjHhsOWKQ/+yed8p+ZwRnhyDf6uypSgLnGS96SRRxiPPAaKzu5SKIEHe27teXU4 U1hNhndHFPYvOLUzTLiFw67iWY4foyK7CBerdOJskvLovE98N05as0DO7OfaMNHWpgEe QKne3d2AUCxUQpqOo1AsZ65ow+ts3yCdOF7ovGYAiPKt/p0WkuY5Vpz4wtiEO+SLpUAM fImg== 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; bh=DQLtyvubo8Ag+Lbse+WNNQzokLJ3Q4fskR3vcwFrrI8=; b=HI/AgzZPr0bU5uhSv9oBefzPQXVkcVv/7r66CHI8VTSp4/L6VKwcL/ktOFS1KcKIyY 5u7a5tWlS8Zm/zLtVl3JcAS6mXwVKMza84Ns7K/0GyNRFWE7KFyjLGH6ya0CCOqo/PCB Aa5Dk2KHEAC0yLwgB+iXNbRM+yJtejl3tSKg75wnE+u1s2pE8j8gHBpzXH3uwuZH3Xgd 1Apcy59icFgWbftpi1tUHr0tJrgsKcYslKjvVyxg+JvMhHy9AV6T3k5qJ3AQqURq4Bq9 QZmPkD6VcRHzlaz1Wv+BFydfPcaIuD236fKM/m8TOEyzNKHJYusKL+jQreJtMTaVh1Ic je3Q== 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 o68si8973150pfo.140.2019.01.19.11.07.52; Sat, 19 Jan 2019 11:08:08 -0800 (PST) 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 S1729261AbfASTGd (ORCPT + 99 others); Sat, 19 Jan 2019 14:06:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40084 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728911AbfASTGd (ORCPT ); Sat, 19 Jan 2019 14:06:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D95DD9FDF9; Sat, 19 Jan 2019 19:06:32 +0000 (UTC) Received: from [10.10.120.4] (ovpn-120-4.rdu2.redhat.com [10.10.120.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA432611A1; Sat, 19 Jan 2019 19:06:31 +0000 (UTC) Subject: Re: [PATCH v2] target: fix a missing check of match_int To: Kangjie Lu References: <5C38F72B.5000203@redhat.com> <20190112053159.99406-1-kjlu@umn.edu> Cc: pakki001@umn.edu, "Nicholas A. Bellinger" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org From: Mike Christie Message-ID: <5C437537.8010304@redhat.com> Date: Sat, 19 Jan 2019 13:06:31 -0600 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: <20190112053159.99406-1-kjlu@umn.edu> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sat, 19 Jan 2019 19:06:33 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/11/2019 11:31 PM, Kangjie Lu wrote: > When match_int fails, "arg" is left uninitialized and may contain random > value, thus should not be used. > The fix checks if match_int fails, and if so, returns its error code. > > Signed-off-by: Kangjie Lu > --- > drivers/target/target_core_rd.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c > index a6e8106abd6f..3b7657b2f2f1 100644 > --- a/drivers/target/target_core_rd.c > +++ b/drivers/target/target_core_rd.c > @@ -559,6 +559,7 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev, > char *orig, *ptr, *opts; > substring_t args[MAX_OPT_ARGS]; > int arg, token; > + int ret; > > opts = kstrdup(page, GFP_KERNEL); > if (!opts) > @@ -573,14 +574,24 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev, > token = match_token(ptr, tokens, args); > switch (token) { > case Opt_rd_pages: > - match_int(args, &arg); > + ret = match_int(args, &arg); > + if (ret) { > + kfree(orig); > + return ret; Just set ret to the return value and then break, so all the error and success paths are going through the same code path.