Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756836AbcJWXhw (ORCPT ); Sun, 23 Oct 2016 19:37:52 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:33433 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753558AbcJWXhu (ORCPT ); Sun, 23 Oct 2016 19:37:50 -0400 X-IronPort-AV: E=Sophos;i="5.31,539,1473091200"; d="scan'";a="23952167" Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Damien.LeMoal@wdc.com; Subject: Re: [PATCH] sd: fix uninitialized variable access in error handling To: Arnd Bergmann , "James E.J. Bottomley" , "Martin K. Petersen" References: <20161021153246.3456962-1-arnd@arndb.de> CC: Hannes Reinecke , Shaun Tancheff , Jens Axboe , Damien Le Moal , , From: Damien Le Moal Organization: Western Digital Message-ID: <4bd72b9c-7826-0bfd-7004-09732c774091@wdc.com> Date: Mon, 24 Oct 2016 08:37:37 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161021153246.3456962-1-arnd@arndb.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [199.255.47.8] X-ClientProxiedBy: CO2PR20CA0025.namprd20.prod.outlook.com (10.163.96.35) To BY2PR04MB1973.namprd04.prod.outlook.com (10.166.111.13) X-MS-Office365-Filtering-Correlation-Id: f8fb2abd-0f17-46a4-56fa-08d3fb9d97ea X-Microsoft-Exchange-Diagnostics: 1;BY2PR04MB1973;2:wOinltOIydMYubz0wU2P8iEwpJpZbyGTrHUofuBtIR9dPzHGYNK8RL5HkRCUlMO4kkvM0M83vB6l4HRf8faelrot/UdWBg8y/m18+dkwhXzk4s0c48xt5KYJ3GHTRayY8wvpy7nLRtrKk7stkBpyeXV75sF/0NyqccXFNVyBCw/bgiRQfK0cJHY4s2fuZA0+9nai5/rpSmMGVJ18hGhIaQ==;3:w0xbV1J/y37VRWXQLbWoBxKaNMYqqF6xb5TCawhUv2tfr9P3ALilmsYcQEOGVq9GTKRFaGQg4F+1F37k41MmjBE/8g/D5f+J9yNPj6rG5s72NO87xgDOR13kccHBJiAC3S6DVKdl6cBdlMstMOqkYA==;25:Z0zLE2NweNcZioH/X7cssWRO3CT8RK083IzZpORlMurHvE81LyET3ZHZnYauiapI4Xb/gVHWIny8bBziP8L6/7JACe5cOkPLIkrWRtX4s9nvkvzeLGcXcX5AaUEHPBlUd8zoQJ65gv6ITCRwiYjtosGJ4t1zHHvFuuEt1ZO1r7s1AqqzkHuY6LOrWQ61UTr6Gu0vdbm8nnAYRv4i99++kkd8ZPSJERhcpRRcL82MCe4hpsW7a49YLU+pP1NW8OMsktGHBA0QqvgxliqO52tFfgEPWwEy+s9mGJZya5UOEXIPvt18e/M+9ZyXNPlnTwrxo+2qwsn1TS+LOLH9xnqfZ17Qn6iTeRE7vbH3NM9K7xwgEZq+uq9rYenEWfeVJwOkjksnnkoSSrlspx5uid333xd+d0+MiGEDERMGzLeuhGA0je82oxA+SrYTpaWg4XEr X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR04MB1973; X-Microsoft-Exchange-Diagnostics: 1;BY2PR04MB1973;31:NewUaWZVHpPT0ihx0qR9sapYoUIQxDzPWv0ep2Ax/joVFpV/VMciIo/OmB5afVZBf8+6Wkmmi62+uoHLZfeMca9cmXWNMykFYTKShgOzkJYiTnAJqBopDy7lh48aOQ1k05hzkHVz2t7L2xr3TQ9YmPygjaaiF0VzqgsILyebfB0mX4DUFxP/tViY8U1Syut71NnRFV85YSHZsX/vcQPIAx47aTJ28m36GIaF93OqiE5IQyd4igRk3iw1nLF49l1L;20:Ivq86MlYK256acG831ud6VWE8cMBVFNU8YqPMg5rhPMVejz2v015IRy5S5keXGUyLJUOQFeS693NNkgkaDccpM1CDuGp6MUR96wZ3cho806xSsMMnb1NSoGmdz/pWhKFbdTFc4scDEsVj/VVtLFPoR0m4WpzdqsSGf4JxzpLHsO4HiwvDlu8r6Lm9nV8UQDffhcvuyeTcfvJoFrWzGt0PsXmlM9147aAIhpbxCzS+WoG0w32Mwayh93U9KifSEul717Xiywqx/FKvhf39G0EiVtJrLVVucBWUaB2Nlsr3SQBdsIWQS78lLj/nJ0aRFLm2a4/d9vEbCRaf9KohWaxJCgYzo3aJr64ps0Bq1Z95r2pcLBteHncoxF6rc8kxVUBXLBspHSmvvZcrdhzq3OQ6fsQ3I4cIs+8yzCdMwNzJVP3J16WH2BilEGMe8sf1yqjea137icmLM1s880fwYVv9x0Cag8sxzLW7YkeMWUg1g5U8FppdNJoVjUmifxqxt1X X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625)(67367480688388)(56741022784758); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:BY2PR04MB1973;BCL:0;PCL:0;RULEID:;SRVR:BY2PR04MB1973; X-Microsoft-Exchange-Diagnostics: 1;BY2PR04MB1973;4:YLrvrUIoRUZbldl32xGwquCZOP3nOcS4wRKJkmftNeEkmsp/Az5cuLoSAzVSNEU3tiu/7FHJfZbIn6J/6wvd+rdVdaumXffJusXUmoVurq3zwsf0IfHkpLvPVGF4AVUHS+I0lPwgVKX1BC480NGfEzUTPSyYPLL0wK4B6ibjfIhBaOMyjfKqk4015+Zd6O6/383T8R09ok71tQlb+Q4bz5IXCPEW8Rj7dX6WGoGxErgt75cxz2xP0CCIrwo92GhSGO6/uNHLLz4ca8KkJQtD9FcZwr4wFDeWaUPeMSm1uwCFjLKhEQ0L3X7v+HbYmvV6XjiikFPI/1J6jA8o+bCo1E78IqdeJcVocCW9cI05jr/DYsYyjK00I+xrNhFVKYjAy5yHDDzTYknov4353XvhPRcVcHSnUUFGSqDkzhZAzgVyl/GYIx+D6eyS5xRNiGFvXGlTDa9SJZEn/S15I0CXsSfm1pyfXgXHJ84zDOXNadrAgT8RKkZRR991Sb/g1U5hdt+Q4Slk+ItqZgYhkdmGea7WLrM6hhL+0dwXAQ7UO68= X-Forefront-PRVS: 0104247462 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6049001)(6009001)(7916002)(199003)(189002)(377424004)(24454002)(77096005)(106356001)(33646002)(65826007)(31686004)(76176999)(54356999)(50986999)(101416001)(19580405001)(19580395003)(105586002)(64126003)(15974865002)(5660300001)(5001770100001)(97736004)(42186005)(2906002)(36756003)(81156014)(8676002)(189998001)(81166006)(7736002)(7846002)(4326007)(23676002)(68736007)(6666003)(50466002)(305945005)(66066001)(4001350100001)(47776003)(83506001)(92566002)(2870700001)(3846002)(6116002)(2950100002)(586003)(86362001)(575784001)(31696002)(65956001)(65806001)(7099028)(18886075002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR04MB1973;H:[10.80.171.107];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjA0TUIxOTczOzIzOklqSm1vNGErUmNxUTQ2TnRMa2FoUVFIdDc1?= =?utf-8?B?S3hTRU40dUNtMXlGeDlnS2xJMDVYTjR4SC9JdlJSVzQzK0F3YjZ6bENwMlZS?= =?utf-8?B?MldTeWZPMXJDSnNvSVpMZlFsK0laMHBjSjYwL2pES1c0NEwrbGhXVzRnbHE4?= =?utf-8?B?RERrdDZyUkFobDdCU29pZFV6Rklrc003Zy94dTNiaTN6QmNibE8xaFhwaU9K?= =?utf-8?B?elpxT1kvNktFUmUxbW9IVzR4Z0dDMU9idmlyYUJpTldoWE5PYno4MHFYMXVy?= =?utf-8?B?MnMyRkVpQ2R3aXU3N1cwbEx5OTJ5VlJyblRMNUYwOTNZUGJaYW1VWHI0Y2lx?= =?utf-8?B?SHI4Z2loWUZYV1RiSklmVXVyUnhwbC96anZ4SjhiZTFCR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rossTenant-OriginalArrivalTime: 23 Oct 2016 23:37:45.0473 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR04MB1973 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1458 Lines: 46 On 10/22/16 00:32, Arnd Bergmann wrote: > If sd_zbc_report_zones fails, the check for 'zone_blocks == 0' > later in the function accesses uninitialized data: > > drivers/scsi/sd_zbc.c: In function ‘sd_zbc_read_zones’: > drivers/scsi/sd_zbc.c:520:7: error: ‘zone_blocks’ may be used uninitialized in this function [-Werror=maybe-uninitialized] > > This sets it to zero, which has the desired effect of leaving > the sd_zbc_read_zones successfully with sdkp->zone_blocks = 0. > > Fixes: 89d947561077 ("sd: Implement support for ZBC devices") > Signed-off-by: Arnd Bergmann > --- > drivers/scsi/sd_zbc.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c > index 16d3fa62d8ac..d5b3bd915d9e 100644 > --- a/drivers/scsi/sd_zbc.c > +++ b/drivers/scsi/sd_zbc.c > @@ -455,8 +455,10 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp) > > /* Do a report zone to get the same field */ > ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, 0); > - if (ret) > + if (ret) { > + zone_blocks = 0; > goto out; > + } > > same = buf[4] & 0x0f; > if (same > 0) { Reviewed-by: Damien Le Moal -- Damien Le Moal, Ph.D. Sr. Manager, System Software Research Group, Western Digital Corporation Damien.LeMoal@wdc.com (+81) 0466-98-3593 (ext. 513593) 1 kirihara-cho, Fujisawa, Kanagawa, 252-0888 Japan www.wdc.com, www.hgst.com