Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1195170imm; Sat, 22 Sep 2018 22:17:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV62KzwO5ONSiJbdxlq0/HWiBOk2WY5QKUaNUazmcTilkdFAFBIljIvUvlpDqm9KgSoAoKfT9 X-Received: by 2002:a63:574c:: with SMTP id h12-v6mr3134281pgm.423.1537679857395; Sat, 22 Sep 2018 22:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537679857; cv=none; d=google.com; s=arc-20160816; b=ZXdZzpOQRz/kZX5rl74xYqPMfYC9FFsKJUXCVwwi2fAZaD+0nSASYPW6oZm4rnEPz+ 8gcmh7cDfxUE9PjreTJv9T+LCCAtQILir/CMvYSv541XzA+2oOriEeI1BpTksOi2hW3+ hDugOIopDioso/lIDId6e1ZQ4rwLWcfaFn/UmhSy2Uylm558yHc9R+r4leqJKNOuTRYe P61t5RfEg5ksqxKMhOrbuWVFVVqN5JGTOLv6FR9gnKi2PZNz333PnP6PN0xasIgm1vKw 3YdXmonPKzkf/CGVzLQ/on80WuJSSJGL8BYzYdvD30hn3EI+PePkKosWh58c6Pu8/+8a LG3w== 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=0nOMLT4vwvw+T11iH8rH3HtusTXip01AKxd4bOx1B4Y=; b=vbRKTFuI3yK/ThNeCV3N+QXHRS/4nrUJCdqGio25LmiFyV31r1GtiX8WlG5eaJFuQL 6PTtThDG51BzHMQpIEOm7qn7vNgtaIuUTxXpTRgnWqFA9lkO/VmdyI9hhxErLWI13Vj8 KfrrOAPh5PuzFl5sgHmo7ojm6PR/yegAwDYdF7tLRkYcmqQrXUhK9PbJRI2Jeq5msyU5 mqP0EyaHLKbe3AdY4ixvcTZbi2Oy+DgfBBB9Ac/kayEWkJ6HyZS2rLGt/86RwWMtrh0a VwIV4U6ZKfeEEy1ovdcwlKhbIdXObg/1dVKEIFlr/Cd7DDZtJeuL4MtN2UQ/XD6JD11m XevA== 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 g6-v6si28770244pgq.240.2018.09.22.22.17.21; Sat, 22 Sep 2018 22:17:37 -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 S1726051AbeIWLNY (ORCPT + 99 others); Sun, 23 Sep 2018 07:13:24 -0400 Received: from mga11.intel.com ([192.55.52.93]:48278 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbeIWLNY (ORCPT ); Sun, 23 Sep 2018 07:13:24 -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 fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Sep 2018 22:17:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,291,1534834800"; d="scan'208";a="82581577" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by FMSMGA003.fm.intel.com with ESMTP; 22 Sep 2018 22:13:16 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Dan Carpenter , Tomas Winkler Subject: [char-misc v4.9.y] mei: bus: type promotion bug in mei_nfc_if_version() Date: Sun, 23 Sep 2018 08:09:51 +0300 Message-Id: <20180923050951.29018-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.9 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 75b9d4ac8b1e..371f5f66a9d6 100644 --- a/drivers/misc/mei/bus-fixup.c +++ b/drivers/misc/mei/bus-fixup.c @@ -178,7 +178,7 @@ static int mei_nfc_if_version(struct mei_cl *cl, ret = 0; bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length); - 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