Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp716073pxb; Tue, 2 Feb 2021 16:30:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwf09vTSatCyFwUkFt3GnKca9SO+QzXYC+5lH1NmTV5hPcx4YKpmyl3510lA1LXCv2r+4s/ X-Received: by 2002:a17:906:f24a:: with SMTP id gy10mr517083ejb.531.1612312241682; Tue, 02 Feb 2021 16:30:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612312241; cv=none; d=google.com; s=arc-20160816; b=Y+60IjCXMBATO1DLrllUqDVWC4oj9C+YPNdT77H95IAOlixYBS8MkeTcZobtYMba1G X8ZBP8Bn2qGptsfAJ9e8Yb/89/x56Bm7UM/K3+M1gyROs8xJYQXTr6ZAQHrWwHCpn4ZD KTFxUgiRzUWlT6oxaIGtTaFfSYbKvJNxiyvJStQ03YCs9B3a7UJjYnt/MVkrvTixeYwt BZ6paodOeb5wQ1fvgdlncLkHkqlvH3o2jsUFtbDN18VfZ8JrOg4uynHvcsxNpUraFXLR qTOxFVhq1tt38nl4B9FR0cKokWQ/1MsQooZSoNoI4pM8iWXjZpRyelJd9CqeIm0R+LAF Ht/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=UH8hyyEmOSvdh8TL9KcULE6T5RYzqlKGpCc2473uhAI=; b=JNGHlB0ICYXCtjDSYGvwJj64Sw7+G3KiaU8BjFQNDEGs7vCk1NXRv24iYr2hyFBrIr 86BqR591TcKnS/e2uM3YezE1w7TcdVCskzCsAzLTVCRciajcSxapgkjMO4ot3vgeMrJs n8vkTdm05h2GFFRWmODvfbBzg0wmze7eZhspnMU+M9ZGHuFEF013oFvbTcDeZUrc0Oly +Osy0XZjzxvFBgE8X4Uy98HaJ+VNqyLx4KUbNyT1XC+EwmGy83QpoUDe9h25d586F+0l kYd66dj1zfbXxrVgExdatxB8U4LsydqE0RDtrvAl3HgBa5yDh5eU4E0/HZlSVVpmH2bL fG9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz26si248267ejb.181.2021.02.02.16.30.17; Tue, 02 Feb 2021 16:30:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238077AbhBBSAE (ORCPT + 99 others); Tue, 2 Feb 2021 13:00:04 -0500 Received: from mx2.suse.de ([195.135.220.15]:43122 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233952AbhBBOIf (ORCPT ); Tue, 2 Feb 2021 09:08:35 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 50039B0C6; Tue, 2 Feb 2021 14:07:52 +0000 (UTC) Date: Tue, 2 Feb 2021 15:07:51 +0100 (CET) From: Miroslav Benes To: Christoph Hellwig cc: Frederic Barrat , Andrew Donnellan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jessica Yu , Josh Poimboeuf , Jiri Kosina , Petr Mladek , Joe Lawrence , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, dri-devel@lists.freedesktop.org, live-patching@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [PATCH 10/13] module: pass struct find_symbol_args to find_symbol In-Reply-To: <20210202121334.1361503-11-hch@lst.de> Message-ID: References: <20210202121334.1361503-1-hch@lst.de> <20210202121334.1361503-11-hch@lst.de> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > void *__symbol_get(const char *symbol) > { > - struct module *owner; > - const struct kernel_symbol *sym; > + struct find_symbol_arg fsa = { > + .name = symbol, > + .gplok = true, > + .warn = true, > + }; > > preempt_disable(); > - sym = find_symbol(symbol, &owner, NULL, NULL, true, true); > - if (sym && strong_try_module_get(owner)) > - sym = NULL; > + if (!find_symbol(&fsa) || !strong_try_module_get(fsa.owner)) { I think this should be in fact if (!find_symbol(&fsa) || strong_try_module_get(fsa.owner)) { to get the logic right (note the missing !). We want to return NULL if strong_try_module_get() does not succeed for a found symbol. > + preempt_enable(); > + return NULL; > + } > preempt_enable(); > - > - return sym ? (void *)kernel_symbol_value(sym) : NULL; > + return (void *)kernel_symbol_value(fsa.sym); > } > EXPORT_SYMBOL_GPL(__symbol_get); Miroslav