Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932822AbcDNSkS (ORCPT ); Thu, 14 Apr 2016 14:40:18 -0400 Received: from SMTP.ANDREW.CMU.EDU ([128.2.157.37]:41991 "EHLO smtp.andrew.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754398AbcDNSkP (ORCPT ); Thu, 14 Apr 2016 14:40:15 -0400 Date: Thu, 14 Apr 2016 14:40:06 -0400 From: "Gabriel L. Somlo" To: Dan Carpenter Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [patch] firmware: qemu_fw_cfg.c: potential unintialized variable Message-ID: <20160414184005.GC7821@HEDWIG.INI.CMU.EDU> References: <20160414093337.GD16549@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160414093337.GD16549@mwanda> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.24 (2015-08-30) X-PMX-Version: 6.3.0.2556906, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.4.14.183316 X-SMTP-Spam-Clean: 8% ( MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1400_1499 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, FROM_EDU_TLD 0, NO_URI_HTTPS 0, REFERENCES 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CD 0, __CT 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __HAS_FROM 0, __HAS_MSGID 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0) X-SMTP-Spam-Score: 8% Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1377 Lines: 39 On Thu, Apr 14, 2016 at 12:33:37PM +0300, Dan Carpenter wrote: > It acpi_acquire_global_lock() return AE_NOT_CONFIGURED then "glk" isn't ^ ^ If returns > initialized, which, if you got very unlucky, could cause a bug. In principle I'm OK with being cautious and initializing local variables just in case, but I'm curious: acpi_acquire_global_lock() (and its friend, acpi_release_global_lock()) are both wrapped inside the same macro -- ACPI_HW_DEPENDENT_RETURN_STATUS -- which either makes them both do something useful, or makes them both no-ops returning a hardcoded AE_NOT_CONFIGURED. So what else do you think could be a way to get very unlucky ? Otherwise, sure: Just 'cause we're paranoid doesn't mean someone's not out to get us! :) Thanks, --Gabriel > Signed-off-by: Dan Carpenter > > diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c > index d999fe3..0e20116 100644 > --- a/drivers/firmware/qemu_fw_cfg.c > +++ b/drivers/firmware/qemu_fw_cfg.c > @@ -77,7 +77,7 @@ static inline u16 fw_cfg_sel_endianness(u16 key) > static inline void fw_cfg_read_blob(u16 key, > void *buf, loff_t pos, size_t count) > { > - u32 glk; > + u32 glk = -1U; > acpi_status status; > > /* If we have ACPI, ensure mutual exclusion against any potential