From patchwork Thu Feb 28 18:17:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 159421 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp987262oce; Thu, 28 Feb 2019 10:32:12 -0800 (PST) X-Google-Smtp-Source: APXvYqyGdw0qBRM/Q/XLnWhh3I3QmyyFupT975x4By+8ZhysBeGOn/TyVD4m5ETNbxRafjc+W3GI X-Received: by 2002:a25:9d07:: with SMTP id i7mr738610ybp.454.1551378732050; Thu, 28 Feb 2019 10:32:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378732; cv=none; d=google.com; s=arc-20160816; b=gJtfTVfUI0x/M6Hj/gb0mH7L/SQcIwrFS3q7z44w7tZMC+lIFVcnSA2VCDxSd36hAx dPs/xFhOmc4CpHbZ8R7lkGUO6Umi+NonV9ghWYwO8e8Jb3aZULzWg6Dq5r/9kahLR/x0 sOPZpppp/WXSgnPFcudA2qOIhu9x3LcIf1QEL9/Vu+g/c6uDQtZ9zvSTTeBd3E9SII7/ mRgqwKMmzYlUpLMLvy7b7RN7lp+N7bySM6eKKOKtbNJ0JzsnXjKyu/UGrmz0NM0jHWeQ walMwvh/UG35zBus4g6MCuvCZEkzXxBsFNZMYcw9xmFZbcEsTWRFkW4RjKTK1Zq4Gaiq 3DiQ== 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=UnkEe3Lz2kCnlXnA1sXksP9chMKTTYD82HqDl1kU840=; b=Z6kD9yi67ImNqwMUYslgyshA0wSwxaYo+XRKFxcg8Br3ekLdi9VoTZJV6YpOanWnLO NUtZ443KPwUSL20QhmaIN2f9TcmoaulrZ26Wyi1OcPWqRfbHV+aPrUgopOr4+Bf0oXta cx2gsiBF7kYlhZMpJud7vqOlirEOkOCIvheEh/b8GThMIjLpQs1QCsQBM6Om88ltf6F/ YU2Chn+HoVP6pGnJNktF0JUHd+Ax3Z1PDKBTtuLTjVksO7wI2PiVJqQ6KEZzhpNBXcdC iwlg+UTPX9ji5VS3mr+SuIBzquP+kw6KyoL3dzJC7nRWaxj2j3mjudLStCaMKWQbrdOz 8HTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VvjMQKkq; 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 i1si10488972ybk.389.2019.02.28.10.32.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Feb 2019 10:32:12 -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=VvjMQKkq; 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]:44698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQTb-0002qi-HW for patch@linaro.org; Thu, 28 Feb 2019 13:32:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQFo-0000aF-B5 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:18:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzQFc-0002Lu-Ns for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:56 -0500 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]:41540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzQFY-0002DG-BD for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:40 -0500 Received: by mail-oi1-x231.google.com with SMTP id e7so17274032oia.8 for ; Thu, 28 Feb 2019 10:17:28 -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=UnkEe3Lz2kCnlXnA1sXksP9chMKTTYD82HqDl1kU840=; b=VvjMQKkq87dHE8JN6XudaB863L88/NbwejEehUfsicdMOnagefwJWLnaZGDDE2NrrB nXYekbKYAatT5TazulPi5p643eQo8zk9VsNIDoWZJcwHiQI4gw22txz+cAPsaC2Diiy6 LbPIJBb4h6fO5hANIOoNmXho9fRfrMnC6E2VuZKHPihQt6/O3W0tRSU5qXTmfFE81Vzv 7PABD1kZJhHv1joLSouC9bI4g85H0Etwpomvhdb1iVBPV0kwqRjWAy+G8OEu3TLyiS/f 5I93k138U0jPBu9PjnGPkObhYoiey9J8/jKkejAoWnIy+qn5l+JRh0/wdgXHNYocvsM8 LcpQ== 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=UnkEe3Lz2kCnlXnA1sXksP9chMKTTYD82HqDl1kU840=; b=ajCGx6XQkWS+3e6F8rrNJjd9xDPr2w6NOukSy5bm8dafU4smqGevl/WdIizHs/ZOMg TAYaLnWcPmklL2hfBxA0fgX+ppWsynPhsZWydlHPYoYiPFBrx7R4uPV3EutWlhl6+03Z JD/2Krtn9Ddv8ig8ZSDb8KCWrHoQYFEKZF53vQts3FqlG/HoV+veyefyAISZ0oCteDWV 4OFJMANdnHrRbkZ1EVLsqYOMLWTrKn2hLa/p8LS0LyUpMTWrzn4wpDxJwzKx8bumjRPC XGM+Yg6FWQj/dts2VCGCzd76Umc6NGVdfh+nKK3uc2YI7618cOgGH93GnUNzP1N2NuTa WQmg== X-Gm-Message-State: AHQUAubYHyCz7xQ0tsDzXSRdBoc7odMcK7tEbsRjsGHFExjTgAQmpNyR aFhhNpWDfnSojaheAQIhew== X-Received: by 2002:aca:da43:: with SMTP id r64mr633505oig.119.1551377847861; Thu, 28 Feb 2019 10:17:27 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id k25sm2751743otl.58.2019.02.28.10.17.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 10:17:25 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id E1ED0180903; Thu, 28 Feb 2019 18:17:14 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id D081B3028CF; Thu, 28 Feb 2019 12:17:14 -0600 (CST) From: minyard@acm.org To: Peter Maydell Date: Thu, 28 Feb 2019 12:17:10 -0600 Message-Id: <20190228181710.2477-20-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228181710.2477-1-minyard@acm.org> References: <20190228181710.2477-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::231 Subject: [Qemu-devel] [PULL 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: Corey Minyard , QEMU Developers , minyard@acm.org 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 0ba5763fc2..37167e7244 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -180,6 +180,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);