Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2004783imm; Mon, 3 Sep 2018 15:47:11 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbnxi46vUl8ZNgj1YE7Y6gm0fChEy478I+nAFbqWpJRxRFAlHeqQ/FZFNmfccU6DmQvCZw4 X-Received: by 2002:a62:b40c:: with SMTP id h12-v6mr31700794pfn.18.1536014831670; Mon, 03 Sep 2018 15:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536014831; cv=none; d=google.com; s=arc-20160816; b=GBzLgw4BVOX5Evm8XF9GX7AQOWr4itr6xZjZPd7/nbZKi5QpZ0uEEm5l7AejcPlJ1Q keJZClQbfZY1/E2T3lspxQEKd0ve1tDj0A4Dwzfw7LTo8vX4rG5yTvHRs0cT62/SvKZ+ x+M7aBJp+dhrgN+efuQJNi/LcKF6ugEshvDSBIHr/4hwDdn53J3tqIK+S8I8A4Of9NAV QQSK+AbzpDwKZk30/f1UlHXfGwYWZUsAj5vZRsv1nJ4eY6OQA6F6UlNbsxheye5vGQ1t wgc2gkaFgCwKFhUumMjob6hpuaQEBsonzPJvaT/5irFCfNkArqY9WGV+5XmUEzHt5p/c SBTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fbeB/ZTkxlJaOdE1fhtqZ2Efow7USzIH02lhNwR5vCA=; b=O6t1CRoK8H7WSpknOIwOWdYqFeH+GkWk5wwqf8NNer02MwlQe+P+6n8q6kQHTYyHJq hodBnyyWZ7bI2OVw+ckSJTkYw3v0foHNM1UtV0Pr50s/GcLyNTIr6VfV+dA7R/HkCz4H NBxLfLXfVhKGPCS1CRi71tN4o+lKtxcDvJ+jpMO652D1tMIExdzUcFU/OmYzlkOEQj1M JhznS3aWuJ7HQSQez/hsTD7ySr2uEG5MWkTRAYLP8cl5eZYWUp0yRuIX6knqh/tEpga0 277FR3RFNhlKjhtLOOjBC20r424xjDd914bGA9nd87xT12EgO/2iiaxMtsvuLb8IMSLu VrzA== 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 c202-v6si22094671pfc.74.2018.09.03.15.46.57; Mon, 03 Sep 2018 15:47: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 S1727079AbeIDDIJ (ORCPT + 99 others); Mon, 3 Sep 2018 23:08:09 -0400 Received: from mga02.intel.com ([134.134.136.20]:28872 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbeIDDIH (ORCPT ); Mon, 3 Sep 2018 23:08:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2018 15:45:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,326,1531810800"; d="scan'208";a="67268788" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by fmsmga007.fm.intel.com with ESMTP; 03 Sep 2018 15:45:49 -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.4.y 2/2] mei: bus: type promotion bug in mei_nfc_if_version() Date: Tue, 4 Sep 2018 01:43:04 +0300 Message-Id: <20180903224304.15989-2-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180903224304.15989-1-tomas.winkler@intel.com> References: <20180903224304.15989-1-tomas.winkler@intel.com> 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.4 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 bdc7fcd80eca..9dcdc6f41ceb 100644 --- a/drivers/misc/mei/bus-fixup.c +++ b/drivers/misc/mei/bus-fixup.c @@ -151,7 +151,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