Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1914768lqb; Mon, 27 May 2024 01:27:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXte50mfpgY9nRImQSUFJd08ZZ0TdCgismeR2zKn2O7uBXYryZ7na+UDUYnMBsDjiDFjBzrbqTCibbkji0nPMqyhg4XBOZwowqr4WIP/Q== X-Google-Smtp-Source: AGHT+IEVmVWX31UKJMrApWuOcY7tfWIGLHyPi+9FFBKDLk1/LgdpUEMyibIjgw7y1YRw6Wkyn0Cd X-Received: by 2002:a05:6808:3a82:b0:3c9:963b:7f84 with SMTP id 5614622812f47-3d1a5c3141emr8248307b6e.25.1716798428885; Mon, 27 May 2024 01:27:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716798428; cv=pass; d=google.com; s=arc-20160816; b=p+3Mz1mkcOCgW8CcuoKkqMKUD+YwT0Ppj5k/a8J4MCeJkMNAeXU+8KcZdNxpmqDMbI mRg/06DtZ5+WhvDV5VsLlH77Ao+d7ymVcuDSjSwYipvkqPRV5IEyDUnAit8D96kBhYzf itDGcHUK7DFW7t+lRExjuvSlEHsDy0Vn4nvdGcp9cYt8lpmZjHgjXCIKuN3g9XOWC3Gw noaqYc6+fSLpoE1v2L20CMDzL7fZDTz3VoeTEmOO8kt6i1o48JT/74xFZBj3mfVU7yja vPleZ5WGjkhm4IJjvImBAu7OIcdKfTmxgg4cAwqiWo9o3VjaZUwyi6D6OLRfP4/1dOvx O+ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/5SBKZRmfn8ClYY/nEFrKLglh6rD618P8LlNAa3InrU=; fh=AAox+EoeqMTQ9791A+O9peF9rLQMHaQo2gu+ZvWLvaA=; b=fU+z/U+Ij5XHxp6YncqA7t4gYHW6GBhEuB43H5gFQBxlZN9mGi+r+BG1FofolGhc6V ULIpIOrHbXcK7dKhLbk1VWb+kOVIvGl2g1dolUIgWL9hgpQdBef5oQQQ+uDSP9L8jHYx qNMeobYHnR4VJmqzcaHJ7oFpuNI4ODMoANZQvYu9aasymB1xgRFf9OCntKB+wd2tJDcw pTIfEty9zgcNhEa+95k/z1hRl80ei0Y7Ir/NkwEtY19wwJQRej+IbjMdvWZ9o5XMP3Ub mu+ko40ArgNhjAS1Qa17cg/92zSE/vykY6c8FO/Rkz1Cj+exUwhT89IHhtbR5xJvIqbS R8pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=kbdidkAR; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-190215-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190215-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-68229d0f9dasi3704079a12.707.2024.05.27.01.27.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 01:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190215-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=kbdidkAR; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-190215-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190215-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3E38B2810CB for ; Mon, 27 May 2024 08:27:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5344753368; Mon, 27 May 2024 08:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b="kbdidkAR" Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3BF34D59F for ; Mon, 27 May 2024 08:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716798422; cv=none; b=RHhIqKGOb+L3EiRWZO5XnoJgEL+EDS7rFQ6k1qLLvU01Et6W9xjWGXWGoF7WLKPJ4UtJwZbi7A6+iRmlS8o4o7P5RxiFJhvikqtgJpA4ZzZoc6nVAT4dxdo7+QtvCEszELuDK36DeHk0+L1AGGn2qZHKDKijnc4OpaMpE4U6ZYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716798422; c=relaxed/simple; bh=o2Cd7FRHxRKyzXe1nYxRHpuLDvQDRWJ5/IpjiVl+PCw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=jSjedTGLm04MdaGpCt6g8EjxMx3/Rml7ktCjoHAvdIQfNvipJNafJWJ7dGVhJl9kGyOoLxQLdmnabfuwBk/xvmbznxLVque+sn/KHiFCgdpOmqSOIo+DO1tBHIhuqtAZWrMR++PWqzFLkDN4V/kAZ/UxZqc5QWTqKcYaWMw7iBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org; spf=none smtp.mailfrom=brainfault.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b=kbdidkAR; arc=none smtp.client-ip=209.85.166.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=brainfault.org Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-3737b33270aso13786835ab.1 for ; Mon, 27 May 2024 01:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1716798420; x=1717403220; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/5SBKZRmfn8ClYY/nEFrKLglh6rD618P8LlNAa3InrU=; b=kbdidkARwHSwzlUbu+afTQLfphDeDpCM+PjqCTmDdT9vhrFV1KRWUb6TqDwRbSFs4/ TuUHa/LHQCKMJheuyMdtp8yp4JoGpmAP5CWNwD2P1FUUW1j+7g4zbGBWczQlE9F44KYg ihaLvng52uGIJsV0BSMiUJHA4o6SFt32Nz3rjjej4TkQ0uNyrBPjb/O+TCyjYUKFUsda ac/Il97m+7fH4ns3FLGSBDwNpGXuf1Wy5J8+aNtC3SMlBT+NAgv0n2/Bo6qFP53T3Uf8 W3dDR+H8gSv5PK1x+ZVg+xwEokAhBWfi3nPbbfrP/6wCKXoyXQ4/19aKe/bayqrXd0u6 mqcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716798420; x=1717403220; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/5SBKZRmfn8ClYY/nEFrKLglh6rD618P8LlNAa3InrU=; b=pvf7nJdfDNCqFShvariSWvPCvlpCG97ge8AOauZrD1vkGGQ1R58QQYIxUpwjSuXAlW NcEBw1SDMlKoD2pG1DWwYu2re7YFjlQMCAwbzG98xbMMlQpPU+63DVfjPpFI0HmItoFQ Oxi5d0WDXbb5Uh9mGpZ/8oaQJe7OWCY7HhTRFySXc7e3KPL/COJ5rpmsdShrw7kX9XNF 1ypP050TNlmZOKMpn+AgVmauNI8DndeYV4amrv+g/g9PAjbl80Nb/vfqUbj/xpXfdiv2 hwbPVYy7H4KoKmu9ofbCPydOjVt1NGPWxQTA+y3koeE62C5tUdwxtUceoQmr5PHpRbdr peEA== X-Forwarded-Encrypted: i=1; AJvYcCWvGaCXD7YAazJ93RvKp/B1agTPq1ZjU/P0FZRDZxGWRGn88+48tjashXck2u7fO2GouEtkdnUa8thXJZyal+mi2Fu73wJ589NF3BhI X-Gm-Message-State: AOJu0YwQZTU0EKzk3VXeQ1zoLojSpCthDj8BMnEXn61a/CERGwGRsOfd nr84zY6Lrv6BhxYB0CJb5TooR5FStnJ/H0aBFeDkPrXCeqQHgm+he0RPN1Dp3XBA/+amsNfGabH Y4rhx+MuAIa4E0Hflmz8M4O8c//Vq8TvrX0EJ9Q== X-Received: by 2002:a92:cf0a:0:b0:373:7f12:bc1a with SMTP id e9e14a558f8ab-3737f12c098mr74389655ab.13.1716798419836; Mon, 27 May 2024 01:26:59 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240527081113.616189-1-sunilvl@ventanamicro.com> In-Reply-To: <20240527081113.616189-1-sunilvl@ventanamicro.com> From: Anup Patel Date: Mon, 27 May 2024 13:56:47 +0530 Message-ID: Subject: Re: [PATCH] irqchip/riscv-intc: Fix memory leak when riscv_intc_init_common() fails To: Sunil V L Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Conor Dooley Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 27, 2024 at 1:41=E2=80=AFPM Sunil V L wrote: > > When riscv_intc_init_common() fails, the firmware node allocated is not > freed. Fix this memory leak. > > Fixes: 7023b9d83f03 ("irqchip/riscv-intc: Add ACPI support") > Signed-off-by: Sunil V L LGTM. Reviewed-by: Anup Patel Regards, Anup > --- > drivers/irqchip/irq-riscv-intc.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv= -intc.c > index 9e71c4428814..4f3a12383a1e 100644 > --- a/drivers/irqchip/irq-riscv-intc.c > +++ b/drivers/irqchip/irq-riscv-intc.c > @@ -253,8 +253,9 @@ IRQCHIP_DECLARE(andes, "andestech,cpu-intc", riscv_in= tc_init); > static int __init riscv_intc_acpi_init(union acpi_subtable_headers *head= er, > const unsigned long end) > { > - struct fwnode_handle *fn; > struct acpi_madt_rintc *rintc; > + struct fwnode_handle *fn; > + int rc; > > rintc =3D (struct acpi_madt_rintc *)header; > > @@ -273,7 +274,11 @@ static int __init riscv_intc_acpi_init(union acpi_su= btable_headers *header, > return -ENOMEM; > } > > - return riscv_intc_init_common(fn, &riscv_intc_chip); > + rc =3D riscv_intc_init_common(fn, &riscv_intc_chip); > + if (rc) > + irq_domain_free_fwnode(fn); > + > + return rc; > } > > IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL, > -- > 2.40.1 >