Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4866864imm; Tue, 19 Jun 2018 00:53:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLSojDkj+Zu+yO+MshzxJIRLBLVmU0ng0DdsLvaJx0tk1BWQdzzNNQNbR1ag1EA9M2tGqFI X-Received: by 2002:a62:9fd1:: with SMTP id v78-v6mr16910971pfk.233.1529394788355; Tue, 19 Jun 2018 00:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529394788; cv=none; d=google.com; s=arc-20160816; b=0Hk++Dl5tanui0Qzs3NcwCRGb8CBpjdyT61dJZhs0omIQJ1nOF0HhgFNY2l9FT2Rj2 oBE0mpw+5+dRs4hSC6HpPyyfnEnpRLTHweh1jbG/xDmtTBUrDzFglxc1FDDflB7kYVtu afI0U6aqlRz3dnNieOX5M8ob8LkQQK2xVuUkTk8xzPvmMJEdxP+1fZIT5eQgf/prcuii 41noxx7VkGA2suiED9nmyH7+s3NpyYCGRkwX6sQAA+PNdLAH5b1HIbl2Kb2Z+9TcCSKB 5xmrgvhGK9xQPAZGfzXBzmlZfANhiV6KNsvOXcN7JnVjLM1NwhSm3pPuhpaJR6irhrSO vj8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:arc-authentication-results; bh=WdsPyxI1nQeqkB9V9FbDlixuaMjODIf5nbvTS4ZvS4Y=; b=xAuf1sD4GbrkgQtaYLq3rSZAuVtYPlah19mkJE1YBhOrtcCBruKQIoAkg7oAMmvSkU 3j2N5mt7OEY9tOUmiNF8zL9i+fddsGWe5gQ5cMEVPu1/JrE6IMWnVSZkPGuBpD2JFvpj ASxbuAe1fs4UQhsOKhRdzWgBKNOI9dYCFp9v5ETKRhHjdvpAYOb6upRYlIMnf4LZwoky 2ZdLbEv1byqm15w4v98Y7UCgD5G8VzOSNK/c1LHKFB6ncKZlEC3Rhnf6+y/uqtnjUEuF KB1CkEt8ytZFqqwKhpI8y+rp4xUbrz95pdy3egMVjEetmDxbw8VEfmVemkw4dJTey4Vt kvlw== 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 x16-v6si15782158pfh.354.2018.06.19.00.52.54; Tue, 19 Jun 2018 00:53:08 -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 S937384AbeFSHv6 (ORCPT + 99 others); Tue, 19 Jun 2018 03:51:58 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:46721 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937201AbeFSHv5 (ORCPT ); Tue, 19 Jun 2018 03:51:57 -0400 Received: by mail-vk0-f68.google.com with SMTP id b134-v6so11096706vke.13 for ; Tue, 19 Jun 2018 00:51:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WdsPyxI1nQeqkB9V9FbDlixuaMjODIf5nbvTS4ZvS4Y=; b=H+Du+sYdM7hQupnyVDsz8rdgsvyAgAzMj582lvU5Wz9wCqmsjy1/SyJD0ql5TVBlsE 3eYHUDXD90Vz7VyYYNhc4gBoU3Qi8fzM6tY3Sdh6fl1q/zzuVC+9OfsLEojm73+wH5PW 8j4ievsKbKNY4BU2m8pLnxZzFROvFp3XUfVmTTnZp4s8XQyWrqIiez5mF02X96c98zsp qcy8Ibpi0fQvTps98HpEhWrcwrhfOVO2l+dw1/DPj/RxI7bspwpmvxSS+vFcqMPy5+bV TFAEdTmlX3m98b5GRODA6Ozs/bBOc/w/ItHGhXlfBQnKEDFyJJZk11UOgkracUVfV4FU icHg== X-Gm-Message-State: APt69E17P7wravfGXSaZ7rF7GwJFjCuBfMsSHYdi2Cq3xcwEH2Bk9Hi3 uss+oyrhH9bovJa3ncRm9Fn6AmKoX/7SfnT8hE0= X-Received: by 2002:a1f:2c0d:: with SMTP id s13-v6mr8807630vks.106.1529394716162; Tue, 19 Jun 2018 00:51:56 -0700 (PDT) MIME-Version: 1.0 References: <1529347999-9316-1-git-send-email-hofrat@osadl.org> <20180619073709.schatjhjoitfc3fs@mwanda> In-Reply-To: <20180619073709.schatjhjoitfc3fs@mwanda> From: Geert Uytterhoeven Date: Tue, 19 Jun 2018 09:51:44 +0200 Message-ID: Subject: Re: [PATCH] staging: board: drop refcount in success case To: Dan Carpenter Cc: Nicholas Mc Guire , Greg KH , driverdevel , natechancellor@gmail.com, Linux Kernel Mailing List , Geert Uytterhoeven Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 19, 2018 at 9:37 AM Dan Carpenter wrote: > On Mon, Jun 18, 2018 at 08:53:19PM +0200, Nicholas Mc Guire wrote: > > The call to of_find_compatible_node() returns irqc_node with refcount > > incremented thus it must be explicitly decremented here after it was > > checked for non-NULL. > > > > Signed-off-by: Nicholas Mc Guire > > Fixes: commit 72ee8626eeb1 ("staging: board: Add support for translating hwirq to virq numbers") > > --- > > > > Problem located with an experimental coccinelle script > > > > Patch was compile-tested with: x86_64_defconfig + STAGING=y, STAGING_BOARD=y > > > > Patch is against 4.18-rc1 (localversion-next is next-20180618) > > > > drivers/staging/board/board.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c > > index cb6feb3..8ee48e5 100644 > > --- a/drivers/staging/board/board.c > > +++ b/drivers/staging/board/board.c > > @@ -64,12 +64,13 @@ int __init board_staging_gic_setup_xlate(const char *gic_match, > > irqc_node = of_find_compatible_node(NULL, NULL, gic_match); > > > > WARN_ON(!irqc_node); > > if (!irqc_node) > > return -ENOENT; > > > > + of_node_put(irqc_node); > > I don't feel like this is the right thing... We should keep the > reference until we're done with it. Which apparently is never? Indeed. The reference must not be released in this function, as it's stored in a global variable, and used later. As all users are __init, it could be released when the init section is freeed, in theory, but there's no callback for that. Hence: NAKed-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds