Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753141AbbLJT4c (ORCPT ); Thu, 10 Dec 2015 14:56:32 -0500 Received: from mx2.suse.de ([195.135.220.15]:34981 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752537AbbLJT4a (ORCPT ); Thu, 10 Dec 2015 14:56:30 -0500 Date: Thu, 10 Dec 2015 20:56:27 +0100 (CET) From: Jiri Kosina X-X-Sender: jkosina@pobox.suse.cz To: Minfei Huang cc: Jessica Yu , Rusty Russell , Josh Poimboeuf , Seth Jennings , Vojtech Pavlik , Jonathan Corbet , Miroslav Benes , linux-api@vger.kernel.org, live-patching@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [RFC PATCH v2 4/6] livepatch: reuse module loader code to write relocations In-Reply-To: <20151210142032.GA2399@huangminfeis-MacBook-Pro.local> Message-ID: References: <1448943679-3412-1-git-send-email-jeyu@redhat.com> <1448943679-3412-5-git-send-email-jeyu@redhat.com> <20151210142032.GA2399@huangminfeis-MacBook-Pro.local> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1415 Lines: 41 On Thu, 10 Dec 2015, Minfei Huang wrote: > > + klp_for_each_reloc_sec(obj, reloc_sec) { > > + relindex = reloc_sec->index; > > + num_relas = pmod->sechdrs[relindex].sh_size / sizeof(Elf_Rela); > > + rela = (Elf_Rela *) pmod->sechdrs[relindex].sh_addr; > > + > > + /* For each rela in this __klp_rela section */ > > + for (i = 0; i < num_relas; i++, rela++) { > > + sym = symtab + ELF_R_SYM(rela->r_info); > > + symname = pmod->core_strtab + sym->st_name; > > + > > + if (sym->st_shndx == SHN_LIVEPATCH) { > > + if (sym->st_info == 'K') > > + ret = klp_find_external_symbol(pmod, symname, &addr); > > + else > > + ret = klp_find_object_symbol(obj->name, symname, &addr); > > + if (ret) > > + return ret; > > + sym->st_value = addr; > > + } > > } > > + ret = apply_relocate_add(pmod->sechdrs, pmod->core_strtab, > > + pmod->index.sym, relindex, pmod); > > It is more appropiate to test the ret. And if error is encountered ... then you'd propose to do what? The code is correct as is; the return value is propagated properly to caller, and all the existing callers have proper error handling. -- Jiri Kosina SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/