Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965496AbcCKIyd (ORCPT ); Fri, 11 Mar 2016 03:54:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58341 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965105AbcCKIwz (ORCPT ); Fri, 11 Mar 2016 03:52:55 -0500 Reply-To: xlpang@redhat.com Subject: Re: [patch] kexec: potetially using uninitialized variable References: <20160311080747.GA31887@mwanda> To: Dan Carpenter , Andrew Morton , Vivek Goyal Cc: Dave Young , Xunlei Pang , Ingo Molnar , Toshi Kani , Mimi Zohar , Minfei Huang , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org From: Xunlei Pang Message-ID: <56E2875B.8010909@redhat.com> Date: Fri, 11 Mar 2016 16:52:43 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20160311080747.GA31887@mwanda> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 983 Lines: 34 Hi Dan, On 2016/03/11 at 16:07, Dan Carpenter wrote: > At the end of the function we check if "ret" has a negative error code, > but it seems possible that it is uninitialized. > > Fixes: 12db5562e035 ('kexec: load and relocate purgatory at kernel load time') > Signed-off-by: Dan Carpenter > > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c > index 503bc2d..63d1af3 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -795,7 +795,7 @@ out: > > static int kexec_apply_relocations(struct kimage *image) > { > - int i, ret; > + int i, ret = 0; > struct purgatory_info *pi = &image->purgatory_info; > Elf_Shdr *sechdrs = pi->sechdrs; > Look further, there is a condition at the beginning of the for loop: if (sechdrs[i].sh_type != SHT_RELA && sechdrs[i].sh_type != SHT_REL) continue; So, I think that's ok, but I don't konw if GCC is smart enough not to throw warnings. Regards, Xunlei