Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp489128lqp; Sun, 9 Jun 2024 05:41:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVV8E7E3+CXlwk8GHKDZ/Wx6j+D73b8QmCCp6Pe2y8vdmZfSuDQ75vS2uWq8Cqs+r6RuHfH9W3fW123HgwduVi6OmzWWZoKJSuJlzH1qA== X-Google-Smtp-Source: AGHT+IF6jBpp9p5MZN2cfb8mCZ1dYmDLE9y0hhH4YCmkVWq0enXNfxJTIIEQGhY2VjQap5q4RvPJ X-Received: by 2002:a05:6359:5f94:b0:19f:1e0c:e1a1 with SMTP id e5c5f4694b2df-19f1ff98853mr878887055d.22.1717936907885; Sun, 09 Jun 2024 05:41:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717936907; cv=pass; d=google.com; s=arc-20160816; b=H63CxfzgZui64MWKlnTCFVZ2Ym6gKIegZFEY/z+IINQ14njDudkA+sjaFq9OHihKpU 8VioHTC9VNCjvZgAcA8oCpr1O4rUw20SUGMcYB+EeKbdaAGsamaAPyUfwRyaJqi+JZL9 9NvOsOa0L2uION2lWQRN0RdFbgdWWZmLuwJyQRsNytazjBkKiuVaRK49EMFgxKgUwK7E C6nuCo04ldpHeKlea9n+JuVIrHKc+vp7DSqv+Xq6449DhN2UYzh8eeW2XxBHCNcLV1+w XarxB8X5b0bETi5VvXvCoeGi/V5FS9Qd8qLS4TeM2y6CoPM9kUSPJXfpQ0VDaQYNtpi9 HiKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=cf23nxdHeFgkRwPVZrD1JWaI4FpEFwucMzstBOMHqWA=; fh=/yTd/AhrK1AELlETNNgyE/VTMugn6+sN23OFxxJictU=; b=Z/Y34XY/cYryaV7JOdfCaGw9z0/ekF9PgbecQTxiWOvY/ktNdFUvssuv8pOWI8AxpN 21FqW2L7XGqpFY7msrEhLa9gK54/2CUeWbrWO8yjrENMtBy10TwSSWwgw+ZGHlWYJtTY ZoZVy2/q1KwJrMJ0neQrGXLXlr6oVk+VP/CUPc2VawUdWUr5v90yYnx6ihft4Z/4N4fy Omy6fO7M8UQ/hey2ieFYs74XLDPfY1KS4ntZrUMT+5zxBnG/SO3nV5Pj7it+tcH8TpIT N8RTeEChPet58FT3hISiIa3X16Wqc1qS/qzJ6VRIXC6tcxV8IMpHN4xh62ql2i0Lj+f9 OUzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NIW7TVXi; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-207359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207359-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2073c4c9si3015063a12.60.2024.06.09.05.41.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 05:41:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NIW7TVXi; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-207359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207359-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 99092281565 for ; Sun, 9 Jun 2024 12:41:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AA653F9ED; Sun, 9 Jun 2024 12:41:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NIW7TVXi" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 6ACA52E64A; Sun, 9 Jun 2024 12:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717936899; cv=none; b=iyKswC5vb8evItpLvzYEsm0Xldt2EWSHmfuu1YhqajvBRCCdou1Gry33tBQDsr2otecxf7erPeppftW8+yqLFcrUAxtfM8NW77IdFz0zQTAxnWQivdWabCHaFCXwqUdR8ldSiu5WtyGM8iu9ceK8/sn7EnvKLo+mK05X7g+0g0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717936899; c=relaxed/simple; bh=VxQ5ZVnh61dCaKiBJCdTdFoMX88pxW2Juk0q/pYhdRw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=sc37fJKNXbSzmMyAy6+lQhb+Iu619GsXLagYS1SoPco9oQwgdgpD1GBwY99Bqz2gwDlVrU4T2wsjK/WPODiVMVVxsigKYBQl3sr0JCTbJC3vT/P2Cfev73MFMOk8hOv+Q8c4oM7FEoY767NmPmVpKRbmzQTYRX/oHYAiT4NiDZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NIW7TVXi; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1f6dfc17006so13011095ad.0; Sun, 09 Jun 2024 05:41:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717936897; x=1718541697; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cf23nxdHeFgkRwPVZrD1JWaI4FpEFwucMzstBOMHqWA=; b=NIW7TVXihRaiYaOfvVqk9BckyxW/xmQ9sRAwuXuAXgzT/ddv0tUCoE7459cJkGKbgw c6sRL1xIbcRJZIXpBj8gq5pIf4J4pOjyTLtNktoOjCjkKtBML/RYfGJ72ZupzUpltjaK tFw9Db22aHd+cjQri/r0o2KHqho2dlKBlAwv6GLdh+stxPbV4koX0RUtl+aiuMiSjE7A CrLYjRMq7VVPYAQlxMS/p9aPDu+08BH/+XbdB4VlwcDKPv1mXWOF+EfGnHvc+uuK+HrU 8eS0gR8Ch3l/jvhmSfcQbzcjxgMdu3Ui0zPwjU7/1cNfK+f1uHYWXYib1F2PYbcxLQOq VQFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717936897; x=1718541697; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cf23nxdHeFgkRwPVZrD1JWaI4FpEFwucMzstBOMHqWA=; b=rWUc5qMUl0c3SzpbGWJd3pukaZcKbuJmwgUbY5qRDVNJKhrn8RsK8Y/LLS40hxMYZC WVgtDU2+9WlDKMHDH8VGzJYdl29Y/RQNYJhBnjkzlX72UhXkduNmGR9yMdv4SdCwm1Wy k518NVYppsaV8GHIE5nXyuBtYlrwHi55cGVlnljbnUUY2DcwGEmHrN4V/Zth1BBAEok9 m89nMNkKCtMb4f7osmscNXFGvSqUMHZSmaAaOZMBLR72Q9PdkGus1Yzn55bBapmitsMO 1QdTedx6WyM0Hpen5H5MlVVM7z7oEybrfOr3pfWIZ4eiR7H0FVu3XGw/8bJlO6EV6kmd B4eg== X-Forwarded-Encrypted: i=1; AJvYcCXx1c878hcHNrXtpj8kB2QF9NpGV+w0r4CmYcEOaTLd4HC3Cl+y5Gisb4nY5nM4i9JQA3eUHmM9/KPt6BS5oSvpSuSYpkzJnTnbP59mjSkgs+RVuvrnBw1FHosj+v3w+gAd7GvGXtXSfvjsyDa3 X-Gm-Message-State: AOJu0YzBfuctXMCQQiBvHsn1nbELVyTLQxijqhMugI44sl7Xk7QALRTK GuujHC62yPr0hhXU/UhxJz9n482rhb0R4W8QrkEf4Rts8o0hsGZXw4UX3al2 X-Received: by 2002:a17:902:c401:b0:1f6:751b:f2c with SMTP id d9443c01a7336-1f6d02e6b25mr77675145ad.25.1717936897520; Sun, 09 Jun 2024 05:41:37 -0700 (PDT) Received: from dev0.. ([49.43.162.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6bd7d2ee7sm64933735ad.168.2024.06.09.05.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 05:41:37 -0700 (PDT) From: Abhinav Jain To: keescook@chromium.org, tony.luck@intel.com, gpiccoli@igalia.com, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Cc: skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com, jain.abhinav177@gmail.com, julia.lawall@inria.fr Subject: [PATCH v3] pstore/ram: Replace of_node_put with __free() for automatic cleanup Date: Sun, 9 Jun 2024 12:41:24 +0000 Message-Id: <20240609124124.51166-1-jain.abhinav177@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add __free(device_node) to the parent_node struct declaration. Add initialization to declaration for ensuring scope sanity. Remove of_node_put from parent_node struct. Suggested-by: Julia Lawall Signed-off-by: Abhinav Jain --- Submiting v3 after making Changes as per feedback shared in v1 and v2. Patch v1: https://lore.kernel.org/all/20240415161409.8375-1-jain.abhinav177@gmail.com/ Patch v2: https://lore.kernel.org/all/20240605214944.22113-1-jain.abhinav177@gmail.com/ --- fs/pstore/ram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index b1a455f42e93..f8258e4567c3 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -644,7 +644,7 @@ static int ramoops_parse_dt(struct platform_device *pdev, struct ramoops_platform_data *pdata) { struct device_node *of_node = pdev->dev.of_node; - struct device_node *parent_node; + struct device_node *parent_node __free(device_node) = of_node_parent(of_node); struct resource *res; u32 value; int ret; @@ -704,14 +704,12 @@ static int ramoops_parse_dt(struct platform_device *pdev, * we're not a child of "reserved-memory" and mimicking the * expected behavior. */ - parent_node = of_get_parent(of_node); if (!of_node_name_eq(parent_node, "reserved-memory") && !pdata->console_size && !pdata->ftrace_size && !pdata->pmsg_size && !pdata->ecc_info.ecc_size) { pdata->console_size = pdata->record_size; pdata->pmsg_size = pdata->record_size; } - of_node_put(parent_node); return 0; } -- 2.34.1