Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4882177imm; Mon, 11 Jun 2018 21:53:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLzg3dmQRkUbkHM7D1zL9ZIYXEy+SYIrqaRxZbi4wgP6/hTeyEC8AqkfcJeH+GG0gk4ifNc X-Received: by 2002:a17:902:be0d:: with SMTP id r13-v6mr2228469pls.299.1528779194859; Mon, 11 Jun 2018 21:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528779194; cv=none; d=google.com; s=arc-20160816; b=Oh5bOLANuigDaRR6wdC382IorlMgIZrD7jqCbrf6W9KKBJ1Fqdjx7Z4I4Sqm1Bx8km l7Lxstpzg3HRQsuCCA9L727eKiYD7oOmPvcOlWLT1sLN7A6oh79mn1G3uPB7d2DwdAHX GdJNPSlMwcoBBO98OnF0egW5PvjNLlllQiDXc3Ka0j5YqJWNOyuXkv/04dS0mpffvEaZ 6NZDbBe36AeI4B1X4vT/YBEOqQLxawOXl4rfJfOzL1mxIrFMysgRi+EUtwLi8CYibtQ1 W36aawJXQZ4vsWO+0wxWKUYRU0WOlQXAy5VIviNU7Dqfv7ERSNp0qxLu4ffOPJNskHXD s8Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=m14ufEtRSa+LUzqFSxg+yOEVHxaSLIpqRPCDa7ILFqA=; b=aR9z4STPN5yc/7hjfPvE8TLVZgSB9qXmQLNXrfAVvIGgYv/YScjw7Wqes3PTMC5Prr TLWyJQNpXZifp2EM3ANtyLyHpzDOz3BViiLh/LGZB8U3Jw3EcxN5+r8Rh1KxatDEPlRD PLkqnblgyEq2xx7EP8QeMvILUkeH+ZQpkp7iYmwpEbBB4bHnLQ8bPjxVIzeIR+yISw2R D6EL/WCSmN92slhjDlS2n26Lio1avvsNCKzy5PfjvIjdwjsdv1fMrLFh86PMqRISUomc wNnN9p4UEVOF+RkCULixBSBKzO4TdV09BYO+rZa8BpqUuG1hRHhT/FTasNrWziJU9yJ3 1vqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=JLqL31PH; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1-v6si18918825pgr.489.2018.06.11.21.53.00; Mon, 11 Jun 2018 21:53:14 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=JLqL31PH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbeFLEwg (ORCPT + 99 others); Tue, 12 Jun 2018 00:52:36 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:40853 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751861AbeFLEwe (ORCPT ); Tue, 12 Jun 2018 00:52:34 -0400 Received: by mail-pf0-f195.google.com with SMTP id z24-v6so11423161pfe.7; Mon, 11 Jun 2018 21:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=m14ufEtRSa+LUzqFSxg+yOEVHxaSLIpqRPCDa7ILFqA=; b=JLqL31PHxA4O/P8WhlrF/2n44rQSyKZYQPLOW1uhnAdV0egeWotdVEKAyYpR+JQdKo 4NCsIPFYl7m6bkBoricNOX4t/GDEHG2lV1wpbbAuI3HUfInzU5Vvnkk9KvW9Lc4YDRsg sOMW5K3r3mdrqUKjEASYSzlAxRci06orkvEuEkez1qlpyZTrq809nQ7gBCrVms83SfFA ZNFTUMP8U4VxsGj//JVFCpoaf8Gcg2plYRJtrMx904KQZi0mCq4wjtgfLECjgsC4vZ6G 9gnZn0h/Z/b7OwfDgGYiLaGUMS7RR6rjVHxlEI8srGUDRXIS+MGKmV8p2jKs4Su3iF4w cycw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=m14ufEtRSa+LUzqFSxg+yOEVHxaSLIpqRPCDa7ILFqA=; b=j9OmhNrHEZcLa+r+lQNppR3rP+scbLH0uafqXBOLecBVcVZBK3D03/0ZhFV1b3tzsp YonEFiC5k2c3OQD5+rf9YT2LhCkG2oShxcdZ30Oo6jRxE1K+DihywzhEvt/sX7xGsIH0 zo7w0AR39MttLTDWMgtpoff+o3ogaQew9BhdQVx8FFCugHqz/wgUrjJuasLuoU6ewDRu i/kvymFRppGoKfpvCLJnTU3ahkdfJRdaHwyEi/lixfxevVkwuShu1rWZIICx6yBC+WiR zdDfIrvCN4O6CHl9hVMKmujwYp+UPyAu1YK4K+8Rydk0xYsA52pmhFMxx2h+Fk/LN0pr ZDKw== X-Gm-Message-State: APt69E2vlBoQN4TIP1VuqxuR2EcITw+1QatxbchYNzp9Bz1drWcFSnsn FT1qZoe/ECIZOm8nQo/9hptYktQcJsI= X-Received: by 2002:a65:644f:: with SMTP id s15-v6mr1847820pgv.228.1528779154241; Mon, 11 Jun 2018 21:52:34 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id p12-v6sm27331565pfi.175.2018.06.11.21.52.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:52:33 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , "Nicholas A. Bellinger" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] target: add error handling for match_int Date: Tue, 12 Jun 2018 12:52:28 +0800 Message-Id: <1528779148-42485-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When match_int fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling match_int. Signed-off-by: Zhouyang Jia --- drivers/target/target_core_rd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index a6e8106..7bc89ff 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c @@ -573,14 +573,16 @@ 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); + if (match_int(args, &arg)) + return -EINVAL; rd_dev->rd_page_count = arg; pr_debug("RAMDISK: Referencing Page" " Count: %u\n", rd_dev->rd_page_count); rd_dev->rd_flags |= RDF_HAS_PAGE_COUNT; break; case Opt_rd_nullio: - match_int(args, &arg); + if (match_int(args, &arg)) + return -EINVAL; if (arg != 1) break; -- 2.7.4