Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1198351imm; Sat, 22 Sep 2018 22:23:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYZvjVXOZZY7sKKNekf2QOGCP5uWt8itn4YxMDesFBS2JBb7LkBXkXg2M5mVD0Iu3+wKlWc X-Received: by 2002:a62:808c:: with SMTP id j134-v6mr4939276pfd.120.1537680191470; Sat, 22 Sep 2018 22:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537680191; cv=none; d=google.com; s=arc-20160816; b=wtGqsN0WNV7Qz4s/f46LMpj3+hhRBXPrN1uxx6fFofUXbdPlN9zjMnqVBrsal6YsZC DYwWFuirxMl8g6eT5CoqF4ELqj152oqg3v7ai1eKR5ubeVT9GZWLzVqKzoy0+qOTNSKi vZHFQwCYJo1srXnUFiYZCfDvgMp2ieMwn1kqTXgMkL2Xlodvx4sqlA+eBlMhyN+LPk5B B6gsHGlVtORk5W5SBvCcAhL8mbRm+7erfyC1CSJixmVZ8mLS/32BkwiAFp5vkVmtcAt2 FZHrqoUKv6Rh3eBKtCQ6kd5/YD7Zjtah8vrWz4DquYvNdw+qqtTUzUARUbYMDGFvWsU8 IQqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=E0OP1aRDK9zIvsgK1CnA3fmgMAfgGSNWqIO1UaT0mhs=; b=BZjhUc8ZAP9aef21EwZBOAl3a3mxd4GpA/J5rjrNxqBD+88oEfy7gECBUu0wSPoZ8F IyjZ8zb9stN7cR5nbukYrQcovnYFPSTIBZFjxLBKJdA9A0QjFqCsvIZLDu66uRx87P4o 5jCIdS4BUvntWotw5Jo3eV0R25mJJOZatUh7hDxhrQ70HWfD9F885zJmVIspL6DMNEVI tafNLn40IrO0dbL0RgakAHhkONU3f9/9Zm/t4DHmfJVOlwm9/sUzH+wwm7HH1vOg2PTD iMtPiZtsRDMogq65ut4tqrriotdA/5qjm/fHMkatfcg50r+t4W14DjBA2keBR+M4JMC3 97eQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10-v6si28351300pgs.40.2018.09.22.22.22.55; Sat, 22 Sep 2018 22:23:11 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726048AbeIWLSv (ORCPT + 99 others); Sun, 23 Sep 2018 07:18:51 -0400 Received: from mga04.intel.com ([192.55.52.120]:23234 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725949AbeIWLSv (ORCPT ); Sun, 23 Sep 2018 07:18:51 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Sep 2018 22:22:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,291,1534834800"; d="scan'208";a="82582225" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by FMSMGA003.fm.intel.com with ESMTP; 22 Sep 2018 22:19:00 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, Dan Carpenter , stable@vger.kernel.org, Tomas Winkler Subject: [char-misc v4.14.y] mei: bus: type promotion bug in mei_nfc_if_version() Date: Sun, 23 Sep 2018 08:15:32 +0300 Message-Id: <20180923051532.27148-1-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit b40b3e9358fbafff6a4ba0f4b9658f6617146f9c upstream We accidentally removed the check for negative returns without considering the issue of type promotion. The "if_version_length" variable is type size_t so if __mei_cl_recv() returns a negative then "bytes_recv" is type promoted to a high positive value and treated as success. Cc: # 4.14 Fixes: 582ab27a063a ("mei: bus: fix received data size check in NFC fixup") Signed-off-by: Dan Carpenter Signed-off-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/misc/mei/bus-fixup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c index 0208c4b027c5..fa0236a5e59a 100644 --- a/drivers/misc/mei/bus-fixup.c +++ b/drivers/misc/mei/bus-fixup.c @@ -267,7 +267,7 @@ static int mei_nfc_if_version(struct mei_cl *cl, ret = 0; bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length, 0); - if (bytes_recv < if_version_length) { + if (bytes_recv < 0 || bytes_recv < if_version_length) { dev_err(bus->dev, "Could not read IF version\n"); ret = -EIO; goto err; -- 2.14.4