From patchwork Wed Dec 13 01:57:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 121699 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4883894qgn; Tue, 12 Dec 2017 18:00:00 -0800 (PST) X-Google-Smtp-Source: ACJfBottvuL9WHFmTGwbRS2kopAIbDqjCbr6ajVqtdyxebdJQFuNugEDMK38mDJefMZhURsYfNqW X-Received: by 10.159.211.71 with SMTP id g7mr4124983plp.15.1513130400293; Tue, 12 Dec 2017 18:00:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513130400; cv=none; d=google.com; s=arc-20160816; b=rtHyP8v62wohQ9+BLKJIpKYsCcQszs3SqYmytQxVRQyLrKl7k1jW9d+qdyQU82i64i 13daJHTNlcLdHK4rCtFyk3iRKBw4LPWsWSxf9G3OXsI6BI1iW0jhvWFz0P7UpUs83y4d GhajnX4nAS4boNkcXsLNrjcUvC20RlsJdAuKzHzCHhBzxv3MvAgv0lGiRyFr0W1gOKTz fcUjZ6zX99M7YnLQV/H05FPraS08Uod4SFKheZs9AovVSl/S83LgxBHm3GS1W29/5BsM XGe7KJsWp6/G9q0Iq0n6XsuFOQ700ktUqwOWksYUK6hEVId3x4h38Xvu9U201EWmpsWC scAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:cc:from:dkim-signature :dkim-signature:dkim-signature:arc-authentication-results; bh=k3zNENSR3egsyKBqwhFmA5T70lslVGW/0/i8FKIoi8I=; b=A8G5FsUitpo51+OgDQO8rIJ4W39IG08RO230r5u3jVv/kPVAqEjX+hJ9IXK731WtdH tdTgIlcVOwCtZANVON0GuYD2n6klSmF8L8wLeZvBfRTOALwdOzJaDcWsJeQ7jiO097Af TL0mWvS5qHwbANyPBAm1WE8yodyEvCpjb/ah+Iba0MO/1n0f+eWAD6fO/flECTCY9zVr A2HXUyuGFRPt+dosxiGDMa/tlX7Ktomrj7/CFPC4nJ8B3OXDaP7GjJ+LxOjAqAwFzmc5 JULMj5y/97QPlT217wG23JQpx4oiIkbqL+N+fMnxlmrL0iERjN7268LR+zdj7Q/R2aIC NgjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=UukdxWsA; dkim=fail header.i=@verizon.com header.s=corp header.b=SJRT3Ipi; dkim=fail header.i=@verizon.com header.s=corp header.b=aIAc4fza; 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=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si425190pls.157.2017.12.12.18.00.00; Tue, 12 Dec 2017 18:00:00 -0800 (PST) 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; dkim=fail header.i=@verizon.com header.s=corp header.b=UukdxWsA; dkim=fail header.i=@verizon.com header.s=corp header.b=SJRT3Ipi; dkim=fail header.i=@verizon.com header.s=corp header.b=aIAc4fza; 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=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753452AbdLMB7z (ORCPT + 11 others); Tue, 12 Dec 2017 20:59:55 -0500 Received: from fldsmtpe03.verizon.com ([140.108.26.142]:44470 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753279AbdLMB66 (ORCPT ); Tue, 12 Dec 2017 20:58:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1513130338; x=1544666338; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Hnw7FF586JVESdHiTXDCj8NCrqzvap2aOHnQ+bhr50E=; b=UukdxWsAoEFHPY7ucNAU/ophymLXupnpPcyCdaMffvG2kseSc45kmM/W oBXDtgtasvWJvyGkJV/s5rRfRlVW9iEFn3ZGud2Tco8UmXYJIBo+8rmLb fzRiL+2ru8oN7VJZdmiKhEWHDrZIftezBGfB9aUDGSDBl6uPhXQ8rv+lO s=; Received: from unknown (HELO fldsmtpi01.verizon.com) ([166.68.71.143]) by fldsmtpe03.verizon.com with ESMTP; 13 Dec 2017 01:58:57 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO atlantis.verizonwireless.com) ([10.255.192.101]) by fldsmtpi01.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Dec 2017 01:58:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1513130302; x=1544666302; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Hnw7FF586JVESdHiTXDCj8NCrqzvap2aOHnQ+bhr50E=; b=SJRT3IpiKvbFB+4pc8V7U412tfiC3le/PGjgkYOztVCUWz9sfv97oITx nHWkQfEyEsuBi2lc+1RGHx3e3v12Nc6KzVN/cgGzNmJ44nDoU1msjrPbe CsI4eX9QAqKKwMypoz/Mlrj3kgkr4IMVMMG7nW/YYZvrpFAVe+yPnvCbN 0=; Received: from surveyor.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.83]) by atlantis.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Dec 2017 20:58:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1513130302; x=1544666302; h=to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version:from:cc; bh=Hnw7FF586JVESdHiTXDCj8NCrqzvap2aOHnQ+bhr50E=; b=aIAc4fza0yOMosY16CprJyZZAnb1y2eBpkSg8GEGkK4WVMlllN76Fl57 IM71c7z3XyvFRW9/eSjqqgzTEsrhaHpaPOmAtb0aLJlb8g+gFXbCRkGjh NSASNoPlnBsKDqeBdCW/21WO5qGVm+foBqxOhzZ6sboZ+va0pkd6Pv3j8 U=; From: alexander.levin@verizon.com Cc: Arnd Bergmann , Ladi Prosek , "Michael S . Tsirkin" , alexander.levin@verizon.com X-Host: surveyor.tdc.vzwcorp.com Received: from ohtwi1exh001.uswin.ad.vzwcorp.com ([10.144.218.43]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 13 Dec 2017 01:58:21 +0000 Received: from tbwexch28apd.uswin.ad.vzwcorp.com (153.114.162.52) by OHTWI1EXH001.uswin.ad.vzwcorp.com (10.144.218.43) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 12 Dec 2017 20:58:21 -0500 Received: from OMZP1LUMXCA12.uswin.ad.vzwcorp.com (144.8.22.187) by tbwexch28apd.uswin.ad.vzwcorp.com (153.114.162.52) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Tue, 12 Dec 2017 20:58:21 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA12.uswin.ad.vzwcorp.com (144.8.22.187) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Tue, 12 Dec 2017 19:58:20 -0600 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Tue, 12 Dec 2017 19:58:20 -0600 To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH AUTOSEL for 4.9 060/100] virtio_balloon: prevent uninitialized variable use Thread-Topic: [PATCH AUTOSEL for 4.9 060/100] virtio_balloon: prevent uninitialized variable use Thread-Index: AQHTc7XAdtkCJqWYnkaufUWJvflwxA== Date: Wed, 13 Dec 2017 01:57:37 +0000 Message-ID: <20171213015722.6722-35-alexander.levin@verizon.com> References: <20171213015722.6722-1-alexander.levin@verizon.com> In-Reply-To: <20171213015722.6722-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit f0bb2d50dfcc519f06f901aac88502be6ff1df2c ] The latest gcc-7.0.1 snapshot reports a new warning: virtio/virtio_balloon.c: In function 'update_balloon_stats': virtio/virtio_balloon.c:258:26: error: 'events[2]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:260:26: error: 'events[3]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:261:56: error: 'events[18]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:262:56: error: 'events[17]' is used uninitialized in this function [-Werror=uninitialized] This seems absolutely right, so we should add an extra check to prevent copying uninitialized stack data into the statistics. >From all I can tell, this has been broken since the statistics code was originally added in 2.6.34. Fixes: 9564e138b1f6 ("virtio: Add memory statistics reporting to the balloon driver (V4)") Signed-off-by: Arnd Bergmann Signed-off-by: Ladi Prosek Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.11.0 diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 07b07b12ef90..a7c08cc4c1b7 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -253,12 +253,14 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb) available = si_mem_available(); +#ifdef CONFIG_VM_EVENT_COUNTERS update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, pages_to_bytes(events[PSWPIN])); update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_OUT, pages_to_bytes(events[PSWPOUT])); update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]); update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]); +#endif update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE, pages_to_bytes(i.freeram)); update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,