Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp722570imm; Wed, 4 Jul 2018 05:00:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfudnJNURUIspS+tOML9NMeRC1JJUsBp27SULM//RcEAjx+k3gEQPvhlwJW4VBY9a1B6xQa X-Received: by 2002:a63:342:: with SMTP id 63-v6mr1622888pgd.290.1530705612533; Wed, 04 Jul 2018 05:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530705612; cv=none; d=google.com; s=arc-20160816; b=JWO0mecF21rSfmc+1g6aBaW9LgOjIlwFdMLImfz54z04KvvLikohbKRb1odhaMTVQb oZ5+S3Cz4ojQ1l8IEXDzuygQsNNR3MWa1MOXCMAOR1oaIrVqOXkS/3CcLzKvgOQtneaP nzAGTkBuX8zJS3YZnx7PV1BI6H3w+P7njwIFp2Hq8tkAQVmnWZ2IhppBjzhD1+e00SdI sJadwIw1caSTcNQU2POjhdntsfLYWZhmDZO2SsrvM/SU9Mk8V4A3st/K21Mcu4DFjh5R 3StQ2kUoKMaf3ubFQmLWvZ4I5SHEhgLPO4FzfgXctXS8AIh/6DlOCqqBUOUR+1DeGfBj 2gfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=Vug9EljCNmVzU/gL3cYpmPeJ5SWdsPdF0gx+5Lghg6E=; b=rCiBA1XlsyhSZDUI2ZpHujCvF/I3gpqBJs8pu3aszejXrUn9ETQwdMWXN+Op1AFr4B 84pqFZyY4NSB3orQIXr+HkrZ+7pgvcJK3rB2hE12Yo3BQ5RPCUQabPm4o3/FnMcSBEj1 Nm9dOBH0Hg/ITQHAbgyYH/ZTDxoJ+PayeznkL9MVd1VAWsFOpzjjms6JKBrGIr+Sdm+z Nn9zMRfm6tSC5JB9Z96zLO3AlUF+YGB6mdKZ2Hhn4Bd/8llGSvPCf9jpA/VVJNS+c0Uh 1c636HOEYXyDkS7aS/lytaLMGzhecizqaWhQ5GQTRcTiowILxSNff2kv/PBEYt6YmONz pjMw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i64-v6si3417503pli.431.2018.07.04.04.59.58; Wed, 04 Jul 2018 05:00:12 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934183AbeGDL7S (ORCPT + 99 others); Wed, 4 Jul 2018 07:59:18 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:57119 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933113AbeGDL7R (ORCPT ); Wed, 4 Jul 2018 07:59:17 -0400 X-IronPort-AV: E=Sophos;i="5.51,306,1526335200"; d="scan'208";a="335413769" Received: from wl6-20.enseeiht.fr (HELO hadrien.local) ([147.127.193.20]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 13:59:15 +0200 Date: Wed, 4 Jul 2018 13:59:14 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Dan Carpenter cc: Tomas Winkler , Alexander Usyskin , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] mei: bus: type promotion bug in mei_nfc_if_version() In-Reply-To: <20180704093449.vryluk7khaudstgp@kili.mountain> Message-ID: References: <20180704093449.vryluk7khaudstgp@kili.mountain> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 4 Jul 2018, Dan Carpenter wrote: > 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. > > Fixes: 582ab27a063a ("mei: bus: fix received data size check in NFC fixup") > Signed-off-by: Dan Carpenter > > 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) { Is this preferred to adding an int cast? julia > dev_err(bus->dev, "Could not read IF version\n"); > ret = -EIO; > goto err; > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >