Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3668829imu; Fri, 30 Nov 2018 04:16:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/WxM1eNkvWSGF+F4TOaELzfAZiDPxVZ79c8JyuphmYoj6Qfnlq1TeGuztabHPwrbQ6xlLLE X-Received: by 2002:a65:4646:: with SMTP id k6mr3401268pgr.153.1543580164656; Fri, 30 Nov 2018 04:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543580164; cv=none; d=google.com; s=arc-20160816; b=qvfQbcbhdKS2+X62ed48b8pf00gdtJwtNIeRvhDZGI46TjeKzmjBI4O5AuykYDCdwf xfkAMusp3XxUsxp9MbfmBdDo4VCDzjrKGo4i+Us4gDcSGFhuGuZfSpWlkVHItEuxPoKA Z4AHevs0xLZvRNt4z/6kYhnOA+bPjkL3lx7AdKtdaGnmATeNHZJSYFns0w6NN80nUNRG 9ZwNWwcEZBrQdngWBj2Eb8Sn0g1qOUwm1ZCaAms0f3HXlVSTGAIzYhs/0VqCLCuQbP03 9GgY6nPSHRUdpSkSn5HoQUEJgGbrEVR+z4/N1Bo15pGlGCGjueO2JaJdXf2j8fahN//8 yWvA== 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=vxzUL1r5Nbe5aoj/SALg/72GaH349weDCX/06RtAMKo=; b=bwrm+D5jdq5Firr6I001I+QoIVXWK2oJTKrjpfhPwvOahAapuzMe89qA944b8qRjpw 3RWfX2IMZ4TFsb6/I0vq5V9UnDKCVZ3YEBe7DBVyktW46MdvM038ckQjz2zq68lFUlpa oQVCy5YV5eGy56C4YpBn9J5lfNKbt/8mrKMU51exN7owO9rcmicf4TnmECDzNxTBkI7C 1bxEdyczmv9/pvFy0dzfuPGjbux3UFLPFDJaAgBrJKiabHAMor2lk5Ya7wBwudjcxs5N m6pyWRww1AXdRchC0yifLlA2Rp8juoimhJ4nAm5y0YZLhMOlnL/b8GEQSL9RHAdDD7DI zTPA== 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 f4si5140206pfc.234.2018.11.30.04.15.43; Fri, 30 Nov 2018 04:16:04 -0800 (PST) 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 S1726589AbeK3XYK (ORCPT + 99 others); Fri, 30 Nov 2018 18:24:10 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:37302 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbeK3XYK (ORCPT ); Fri, 30 Nov 2018 18:24:10 -0500 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gShhC-00038v-Ct; Fri, 30 Nov 2018 13:14:58 +0100 Date: Fri, 30 Nov 2018 13:14:57 +0100 (CET) From: Thomas Gleixner To: Norbert Manthey cc: linux-kernel@vger.kernel.org, David Woodhouse , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, "Eric W. Biederman" , Andrew Morton , Mike Rapoport , Baoquan He , Nicolai Stange , Jan Beulich , Jan Kiszka Subject: Re: [PATCH] io_apic: initialize irq with -EINVAL In-Reply-To: <1543403393-6004-1-git-send-email-nmanthey@amazon.de> Message-ID: References: <1543403393-6004-1-git-send-email-nmanthey@amazon.de> User-Agent: Alpine 2.21 (DEB 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 Norbert, On Wed, 28 Nov 2018, Norbert Manthey wrote: thanks for the patch. > Subject: [PATCH] io_apic: initialize irq with -EINVAL io_apic is not a proper subsystem prefix. git log should give you a hint: x86/ioapic: .... Also please start the first word after the colon with an uppercase letter. Now 'Initialize irq with -EINVAL' is not really informative. It tells what the patch does, but does not give a consise hint, what this is about and why you want to do it. Something like: x86/ioapic: Prevent uninitialized return value provides precise information about the scope of the patch. > To catch the case where the uninitialized variable irq might be > returned. I had to read this incomplete sentence 3 times until I discovered that this is the second part of the subject line. Please don't do that. > As the path that might lead to this situation can only > occur based on invalid arguments, we initialize this variable with > the value -EINVAL, so that callers are notified accordingly, and no > uninitialized value is returned. > > The path that would allow to return an uninitialized value for the > variable irq would require legacy IRQs without the ALLOC flag. Ideally you describe the problem first and not elaborate lengthy on the solution, because the solution is obvious once the problem is clear. Something like this: mp_map_pin_to_irq() has an exit path which returns an uninitialized variable. This is reached, when called with arguments ...... Initialize 'irq' with -EINVAL to prevent that. > Signed-off-by: Norbert Manthey > Signed-off-by: David Woodhouse This SOB chain is wrong. How is David involved in this? If he co-developed the patch, then a 'Co-Developed-by: David...' tag is missing. If not, then his SOB is just wrong here. > --- > arch/x86/kernel/apic/io_apic.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c > index 2953bbf..219dbc1 100644 > --- a/arch/x86/kernel/apic/io_apic.c > +++ b/arch/x86/kernel/apic/io_apic.c > @@ -1031,7 +1031,7 @@ static int alloc_isa_irq_from_domain(struct irq_domain *domain, > static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin, > unsigned int flags, struct irq_alloc_info *info) > { > - int irq; > + int irq = -EINVAL; > bool legacy = false; > struct irq_alloc_info tmp; > struct mp_chip_data *data; Now, lets look at the actual error path: if (!(flags & IOAPIC_MAP_ALLOC)) { if (!legacy) { irq = irq_find_mapping(domain, pin); if (irq == 0) irq = -ENOENT; } <----------- (i.e. if legacy == true) } That looks about right, but to get there something must set legacy to 'true' and the only code path which does so is: if (idx >= 0 && test_bit(mp_irqs[idx].srcbus, mp_bus_not_pci)) { irq = mp_irqs[idx].srcbusirq; legacy = mp_is_legacy_irq(irq); } and this code path actually initializes 'irq'. So returning uninitialized 'irq' cannot happen. How did you find that? Code inspection, static checker, ... ? Thanks, tglx