From patchwork Mon Jan 28 17:54:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 156825 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3720431jaa; Mon, 28 Jan 2019 10:05:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN69glFeAoZsKauRClwyVcOCU/eDBOysCquR8+9yVt7DVMLOsWRUf+/V6M0rldFCe+73aFEi X-Received: by 2002:a1c:ab87:: with SMTP id u129mr18201863wme.104.1548698741099; Mon, 28 Jan 2019 10:05:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548698741; cv=none; d=google.com; s=arc-20160816; b=SNd6HrLmTGFglM6GM1wrDH2Do3rELYuHPv+jO7GpxAtnYyBAlMcn7H0a4b1XUzzZrD XD722cwVZoqsPQao69LxAuoYPU2DupA4CvLygK3xJ+Nqp5XbVqouWm0baseHzamnCx3R VUBIN1iGCGqCnK60FmPqCGT+RHeLKAfvwcKFGZIvtwQSznpnzDU6dkxBCldiaVD9hx+z FjNkXPx87TMoDQauDn7yOLsz+qLDa7N9M9iJvlSwaKFXEbuvkKQxOPFBhRmKl4pXamWo vy+V8gaQ/5+hy+PwahTJj39Es8ORGjiWxMoUbo/35bzenL/RRocPKLCqv6aLqAPuC+kx nMpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=vUBNL7iuL2tms8dcSHLWhPEfJJ8Hjvn6D7ICUweDvw0=; b=uDZkhGc3p98a+Loa2wEZr/SgVFCeKepKh+dFTxVUIcudvFFJmTDcsw69iIf9PEE2ZT D2UpTsbpn32vHWSqn4Ilol+qrcg/+5czEJP+cCElWwMytxR+bmP+vBCd3KzMgOMQcn4c ypU0jmQj3iLB20N40LmL82l3PavV/ENWiWv2IEsafKxVZJMHvRUYvYo2O4oTc2r/6LEJ iAZAAhQzS5Mh1jlzZsVTgPmA+U/w5/YGq+DO+TH24XdEcGT70wNqcAVYxhlejc8p5ZjX /rVmooeXwVvDuNy8uZ5Sos8DSBR9D9MEoSZukoVZSWqdlWJYZ7MSfQbLl32ngZnbSHKn EQ1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=H6HtgR0p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h16si77586106wrq.337.2019.01.28.10.05.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 10:05:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=H6HtgR0p; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:36233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBHw-0005OK-4M for patch@linaro.org; Mon, 28 Jan 2019 13:05:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBEB-0003Db-JP for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:01:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goB8V-0005tq-AD for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:56:06 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:40548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goB8V-0005gC-0d for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:55:55 -0500 Received: by mail-pf1-x442.google.com with SMTP id i12so8329606pfo.7 for ; Mon, 28 Jan 2019 09:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=vUBNL7iuL2tms8dcSHLWhPEfJJ8Hjvn6D7ICUweDvw0=; b=H6HtgR0pz1DUvhzywy1BzBCsYFiWEu5VFy+kYQpl1PGQcBBf/BS1f977d6bQZqn+SV dzoKuorLDsesmBIb1/4J5Je9hA4NrGFpyibbq1A43HeXfc53mcwCV8KarrjHU8pZOLky QE3TWmhyho3LYmC37qdS2vEkCKBRvnVMCTgvhmAKdBaT054aDuW6n2NmZjFoDPBlr3jY sshs+a0WPa6KKgAQwgx31wteb8ltpCx10Ozf996lbZ80JCDj8B+CKeAo4PIpeepW2oI7 HTbFebPg1yqwOIwz+T1E9oqbZ/I+9PTAycN7EBbBVpsaRwjp3SqB0PLkJMpkcraPYYFn 83Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=vUBNL7iuL2tms8dcSHLWhPEfJJ8Hjvn6D7ICUweDvw0=; b=om205cV1CMZXDNM+BcS5woRZ5AFVOq4wo0zQeZkChF8H0bjVqsvyY2suNEnxkr0HzW 6pNIbUAW5TxfOs6TU2q2qhStVsviJpe8tj3PJv6lrKiRCE2AHKVK4S432KVuN0icuQcX S/HYTuxMdzQQLuhZVRaW0pHe2c8rRAGHJ++wlVzhPaBSFHRC+NLFH59AwZS7CC4PHKob JwAJwXooGd8wGZWi41J7NTdqL2DSMKmCBDRBdmec2QovEirydjr9qnuZ/GVw3LZ66izw Zaw/DPvboD292ubkzwVk8HLRBqnFtAmLhM7AVYKxz1WkddS25P8vLwBjKBI7/0P5k2nj gxkQ== X-Gm-Message-State: AJcUukcoiOqxo4YIJfPDp3ozOt/+xBMRmb9eBiz0urnZV5zuwuMSEv4H LZBO+Ih9+h2IBl4/I01zfw== X-Received: by 2002:a63:ed42:: with SMTP id m2mr20756223pgk.147.1548698126981; Mon, 28 Jan 2019 09:55:26 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id h82sm68862235pfa.105.2019.01.28.09.55.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 09:55:25 -0800 (PST) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:c8f8:7971:e432:a838]) by serve.minyard.net (Postfix) with ESMTPA id 23BE7BEF; Mon, 28 Jan 2019 11:55:18 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id BAB4930052D; Mon, 28 Jan 2019 11:55:15 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" Date: Mon, 28 Jan 2019 11:54:58 -0600 Message-Id: <20190128175458.27255-20-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190128175458.27255-1-minyard@acm.org> References: <20190128175458.27255-1-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v4 19/19] i2c: Verify that the count passed in to smbus_eeprom_init() is valid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Paolo Bonzini , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Keep someone from passing in a bogus number Signed-off-by: Corey Minyard --- hw/i2c/smbus_eeprom.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.17.1 diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 44887b4a27..ee392f7cb1 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -178,6 +178,8 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, { int i; /* XXX: make this persistent */ + + assert(nb_eeprom <= 8); uint8_t *eeprom_buf = g_malloc0(8 * SMBUS_EEPROM_SIZE); if (eeprom_spd_size > 0) { memcpy(eeprom_buf, eeprom_spd, eeprom_spd_size);