Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5479671ybi; Tue, 4 Jun 2019 07:17:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVlwkXes/Ghw38Aptyotw+oNy6yZSbdJB4NP2sV6qRg9A3YchTrXUaI3JpbcwaDp4sSOL/ X-Received: by 2002:a17:90a:2648:: with SMTP id l66mr8987214pje.65.1559657872070; Tue, 04 Jun 2019 07:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559657872; cv=none; d=google.com; s=arc-20160816; b=dEUb0/0PfgBrQ/MED6ljmj9iPvDHMrBhT8HOg56bORLdmAj4kkdFfgQzzIVqcXMtxW vxGQ1gvUXNKIfyS+BEwad4aAbXjcMPel2SBfcxfIQ1aCee10WeZMWRIaXzHIpHVtrhu7 umuL/P8A+LNpHkPRuisWlIfLOPsddmlAtxRnOl2WosnDsSA/SMpd5gXmA9DxMlJI4Gy9 ZI+jX7/BtJn0GMrpVPVSG/r8VnKUWiIBZKU8GAKqOoSs+uY9LzMYJW382XYZVicbNeZJ jElNXbhhIIeLUXIAYGqms0q8+8mGsFkUnJw8UevH3pbMbfsS06eJmlW2iQ7AxNgiomMP 04Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=Jyg+oaveGYnWpEUVmSf5y9ld8/p//Y7BVNyQOt80ZmU=; b=w+JO9q4L7FQng1M/3ZpB+l51hm1PqXUewlWBEr69r/9wLlQF6lnEe9LEBATnFx3dWJ U79JVkvmQuuo+8YAfn7g3liXwaA4zW5qT4QaEkNg+6QZDJ+wo/9+qZibo+N8Ocf+ByE3 ML5KqIYC/T9JYQ45yvjuzzc9domiqV0BNcf8Su+1FAkmdrTLMcc/fleBXKvseD0omt3P 9omktPGZLPAFYymWFcXR1wsoLp3NYzfAttq767F1wj9N6CMZpbaZ596K6DHhK8KCQ99X f5yvBLvgYiUJcGx2KKnQMAuFyzOCClG0Y/jLh+zf8S1rg0wTJyUn2ZtNkxPOfUfumJKt WodA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si21550966pjk.65.2019.06.04.07.17.32; Tue, 04 Jun 2019 07:17:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbfFDOPm (ORCPT + 99 others); Tue, 4 Jun 2019 10:15:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:48728 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727287AbfFDOPl (ORCPT ); Tue, 4 Jun 2019 10:15:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 57D69AEFF; Tue, 4 Jun 2019 14:15:40 +0000 (UTC) Date: Tue, 4 Jun 2019 16:15:39 +0200 (CEST) From: Miroslav Benes To: Yuehaibing cc: jeyu@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] kernel/module: Fix mem leak in module_add_modinfo_attrs In-Reply-To: <5705910c-ea13-9ff0-0d94-f2311fa510d9@huawei.com> Message-ID: References: <20190530134304.4976-1-yuehaibing@huawei.com> <20190603144554.18168-1-yuehaibing@huawei.com> <5705910c-ea13-9ff0-0d94-f2311fa510d9@huawei.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >> -static void module_remove_modinfo_attrs(struct module *mod) > >> +static void module_remove_modinfo_attrs(struct module *mod, int end) > >> { > >> struct module_attribute *attr; > >> int i; > >> > >> for (i = 0; (attr = &mod->modinfo_attrs[i]); i++) { > >> + if (end >= 0 && i > end) > >> + break; > > > > If end == 0, you break the loop without calling sysfs_remove_file(), which > > is a bug if you called module_remove_modinfo_attrs(mod, 0). > > If end == 0 and i == 0, if statement is false, it won't break the loop. Eh, you're right of course. Miroslav