From patchwork Wed Feb 20 13:59:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 158817 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5060223jaa; Wed, 20 Feb 2019 07:34:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IbN0Mv57Gn/tWx7nHFPh6P3CVadmGMWfatKfbL9ojIRlMDieZ/te0U55ekoucACNxgEpL6b X-Received: by 2002:a25:1e43:: with SMTP id e64mr28834526ybe.513.1550676871508; Wed, 20 Feb 2019 07:34:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550676871; cv=none; d=google.com; s=arc-20160816; b=oQHUYCrxH0DP0gHLvAdwVCX0PDIAUyi1g0gZ+uUd9Uw0XbWeiRN9pDCHsGezgrGu0e kN8Qi3/DHoDEn4Tuhm6LSnF2mwBrrtk/t+kq62yO59fV7pbL/fQJaFpmaj9WH1md6c8w 2VMvlkw+KxK1bXYJnhX52c7hzOEn/O6Cu3Fuyr5u4uVJGNU9xvHJHCz7jUFKdT201UV+ vCezwQczTrFEX/qLceZC5aTnndWw3QBLS0BPUdS3LQJoD8T5WxI8/Ay4pNvdKOErXygH z6yoakqzWHaUh64mLluy15JI/rPqOIWxZed9+T1YVxmzg0Gz7pQIXkJP3OlMy7tqItmC 6avg== 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=OIGzb9Ia9yq3MmFF0UtL4yvEPIt9QX07Z2gtgFi/kwOh/wIY4S/3Em7/434DkRnPp3 OMhEW2Aw/8VTvFpyKhSITORZucbYp+BiqCOWRM+/42Fn0B99htxwaz+1R8pqvSW+mL7H atLqegW/fDJUrm4Ny4pruHBj6ZGFbG+bgAPuRyLjatNzlVRJA4taWUXcPGIEcXW6frgm qqchzER6UHbcrC8G/BjNh1cbGlQOv57yNRwldJFWhAH6eShj3+YaQ8Ii61RtJQYTbuhX JeKRzjLak9E5wUtLx6SQwR2WszlO8cpjLLEZiZ3GV7UdD+HXqCF68BpT9JAnPFLzgBDt Qcww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=sBnF4ppF; 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 j190si11317616ywd.368.2019.02.20.07.34.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Feb 2019 07:34:31 -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=sBnF4ppF; 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]:40939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTtH-0006nL-2a for patch@linaro.org; Wed, 20 Feb 2019 10:34:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTk2-0008N9-Db for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:24:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwTjj-0007cZ-4o for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:24:53 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:40082) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwTjf-0006mH-T3 for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:24:37 -0500 Received: by mail-ot1-x343.google.com with SMTP id v20so8764131otk.7 for ; Wed, 20 Feb 2019 07:22:17 -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=sBnF4ppFXVrauj4d7eoQu9li9O6ASLXW49+bNseY2iVf6TYomXnQ7XEyLYHYKKyh4k 0I/Drs0l/3P1fzC/ppbkRxVZMTyaB0NnWslW79lQRrnk2i4dmUj5n/aLE58wjeQCTu94 qEMoOxKxpjJAWgYmY+y26zahiQLbfCpX1fyLKS3BMt5MLwgb0gLHxz4zWEUznnp6Syf0 dSeQXarPBy0x6v8Sk0LCppFBywpapcLFX/qfSyJoYLVBn7LTAs1+QNVcYd5so4RLYNLC 9e8sU3AQ1T34bP1FrBUsniOsSVkPKwGUeDoB2Iscr0EH1kdmt63JAfKT/MsIIsErutbr Pi4g== 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=qA6okOcNDYpNyWNf7xEo8UpwTVIgRz1UgYGZx7zu25jMD6GWJdn6bsvf3bWptjumVe 9y4g5BRdlFnFF4AFNr2zFfKlLKq3M3bJSxPTigMVlEhiJdszL8Mfg/2oeZRzq240jz63 5xCi//sdAapdb4hgDNhFHW43PUD4LSS4S3i5Qh1Fbyt5XtBxNsgdWFvLh1HNPk8Wq463 TYzCKc3kgOw+8PFWh/bna4miPgiuKrKBzgHdHAB6/ga6EuYBe67BdlcNhCyfLTbs2c4B abc34pifnW3awZRrHTA/WWdfc7FyexQvptt8rAFFhSFZ8N9tWB8pFIIMCwtX6aScpV3d JgUw== X-Gm-Message-State: AHQUAuY7/zbnD7Ew1qgmbDmade+uqtHSk7erJ8twPRf2VxF1qOjfISeb GfeB84Z07D9b5rfcv5MiFnsl7D8S6g== X-Received: by 2002:aca:2ec9:: with SMTP id u192mr6110012oiu.147.1550671221172; Wed, 20 Feb 2019 06:00:21 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id b63sm9483324oih.24.2019.02.20.06.00.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 06:00:20 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 6DABE1808FF; Wed, 20 Feb 2019 14:00:11 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id 46560302A62; Wed, 20 Feb 2019 08:00:10 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 07:59:56 -0600 Message-Id: <20190220135956.22589-20-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190220135956.22589-1-minyard@acm.org> References: <20190220135956.22589-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::343 Subject: [Qemu-devel] [PATCH 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 , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" , "Dr . David Alan Gilbert" , Paolo Bonzini 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);