From patchwork Sun Feb 11 22:36:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohan Kollambalath X-Patchwork-Id: 199520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2130406dyd; Sun, 11 Feb 2024 14:37:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVnN/MMstx1bjLKVppJopVutqP4WJV/JcnjYTLxiSsg776Oc1lvXsZ7o71BwV+P/VUsqxMk+0IIfbgALtCeozeyiG6qng== X-Google-Smtp-Source: AGHT+IHAAWdqQtdpx3pQT4jdD470x3jK39xGuoEvjLti95OnOGB5wSYjhBWSQRgCHU3FUiNDJLQJ X-Received: by 2002:a05:6808:171a:b0:3bd:c58f:ca21 with SMTP id bc26-20020a056808171a00b003bdc58fca21mr6832682oib.34.1707691072260; Sun, 11 Feb 2024 14:37:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707691072; cv=pass; d=google.com; s=arc-20160816; b=VTXe++aNXIt2qAN7osY8f+ECf4KPKO+I3f1hoY/uxmNprJx9woem6wwZXva5gF8Icu +3twcrjcvoupQDjJ+3O8AouHMxgryHiPjVFSbSbS7itnV/a2qav5jkhgdcN8zTyzoswG IiCDtego1o3tgHwrlH/EhHckUhtiE+Ks4FgxMDrOLXYgQPHDG+G3ZqTGtMzzfjsdStKx 49xYifbWybpGvjndxvfYpqK28/fbWh/5MZcfjICZvoSV4V9TGXtn9ce8o9bFINcgR2RK HYQOX6epPHzUm7JLlfFkB/WeaDhoXtybIm3O/DRbUOJuvhYuE1qmMP0cpzwz8GZlhcll z3Tg== 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=LwL2cPgCgo73JKWjoqj3p87QSfksLIJBW6ce7uIk2Us=; fh=eTAJaitAGiJHB7oCOtzWzKiZE4cWWvPbvxRJK4HWMD4=; b=Ot/7dVzrNfNbOk1qeOQYFI7rPtU6AceqMIohXcvV//Y41FlEYBf4ZGmpwCEaFWULJN Do9XlQQWazbmjZc4695vnhrivuBWgkFYfz9j8BDAOsocfXa4ZXXBfxPolQty/IgV8Smo 6xFyR5QLuxC7r9WJpuo8RnqExDcdEuMbji/2CujXE3vh8A0kGzhUetVWssN4WG8fChdu s7L3VDYe7N8M45UpaLGgyzJYKpj6UdPNI58vNn0jkSSmE5O77T6nUSsepNtigoXpu8Cn d1QZCGNbcBhuMQerhu0ks+stDj5NdlEHU1Vl3XouLMk7RqFHBR+bl4HxUo9XHTJGrik1 kJGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=h8hgUpH4; 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-60973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60973-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCVXL+KZlF87k3hPGNUUf4VKOHmDNbXNSXWIGstzarzs3nMF1PF18OfA1Q8EKx62lb1oaAZpL8ccaenvKosDk5Uq80t64Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ld8-20020a056a004f8800b006e0da0114b7si945783pfb.349.2024.02.11.14.37.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 14:37:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=h8hgUpH4; 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-60973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60973-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EE52BB221E4 for ; Sun, 11 Feb 2024 22:37:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB26D1774A; Sun, 11 Feb 2024 22:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h8hgUpH4" Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 74E2F17562 for ; Sun, 11 Feb 2024 22:37:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707691034; cv=none; b=ct9kPZGfZcP2TexYIniFRDS11Yd4osUTlXaCIHcWf/JDF2HjAtAE049ninE13hjYHefyJqsCMnzavJ+8G72333bQSj6LZ6E21ad/15XCV8LJ2tO5ypki+Eh/gaMBmlAdUMoOs6HjkRuD/0OOYtWX7PGxm7RWUylFbwX0IPX6iNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707691034; c=relaxed/simple; bh=6t9CwVYmdoKt02P//MW11oTFv8CYB0bod9mA2PMjpII=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=pwebKRH9sR9Jg8cmgg5P5wuadmIJnBq3Azw7MejeK+rmNVI8Ktjll2qWiz6S7L79VJjmSEtR++QuSOLpr1jemACZbUyPT+MNV26OEQMmqbIXR1dNcORWl1KgYUcpdLunYW5vCjopTkyfckg9VUdKQL4gYWRpgFk85xQ8twt7L2Q= 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=h8hgUpH4; arc=none smtp.client-ip=209.85.167.180 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-oi1-f180.google.com with SMTP id 5614622812f47-3bff4553fa7so1565391b6e.1 for ; Sun, 11 Feb 2024 14:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707691031; x=1708295831; 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=LwL2cPgCgo73JKWjoqj3p87QSfksLIJBW6ce7uIk2Us=; b=h8hgUpH4Jy2rXyNflbL6i2dcwSSFm2FEErtJlFra/ZM09Ff6EuURWTp1HyclYds0Xu EMOaMrBoDo4NMnHxmJHX5jPHio0Hd+GjHR/9tJXoGNJaFDtBpwkqoOrdLvwu8F64plBM Wdg99yV+0fXSM9iGWzqONkFsnuL+Rr2rjes8SGON6fekIqttkkbHUGUiAXjRuah2hgzp N2tJm9HDM4yt9B2WTdf0u+cIjkyhchWHhKDuAWJ0Lbf242cU9hz4RTr886oUe39fsVwh DD0NIwApNO8ctDZXeq6mtQFNehYbshnwns1QVvyEC2NTznrq9OTlerhKd8Odb5T6SC8n ej7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707691031; x=1708295831; 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=LwL2cPgCgo73JKWjoqj3p87QSfksLIJBW6ce7uIk2Us=; b=lutRESQayiLJXbvq7qvqHX54sbF1wwIoDFQ5ABKsTDZeZ6QDTY8d8jBGUpFkjLDR8Q T9L3SzCDBHE3rYOUgNivEOoxaZmlhb3ShiToU7hRa6M+Bu4DDT+3y4SNSU6JfV49VyXG Tlpoq6OUMsw5ItMkuHaZdM/VoYBnMxybd81mpxzFMvFu3QlQoWQbWLLI1Ao0AfKDBzrZ aTfZm+u1HkuAlTkBzpqLos2pgu9UVnCdvzQkq+hRg3nOMwYzfIi+vsrCaktAJdXekeA2 1eiuMZ52HI/Xz2UBmNeTXYtQAysQ2677AyZPSVXYoo3CouiWeU9ZH0qJodqerJmCZLhg PmLg== X-Gm-Message-State: AOJu0YxzQu0V608ZzG/HJ1Ynj8MYre7H2MphZEVV4jf4qwTWKl/PnEi+ X3PRVTMK6dtr2c4vZ4eToPWD6+WHoQk5ZV9FbIJuNQF8I2QVZISF X-Received: by 2002:aca:130c:0:b0:3c0:3b3b:1745 with SMTP id e12-20020aca130c000000b003c03b3b1745mr157037oii.54.1707691031182; Sun, 11 Feb 2024 14:37:11 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWSSTGYOye8W97pmZkft5mGS2lUrPc6vfsm12c3jsP9weo9admjDQH7e+U7TZmfQf/IeXu4xpIzWfZBlEgp7Kk51g== Received: from opengear-rohan.test.bne.opengear.com (brisbane.opengear.com. [60.241.24.90]) by smtp.googlemail.com with ESMTPSA id k70-20020a633d49000000b005cf450e91d2sm5558724pga.52.2024.02.11.14.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 14:37:10 -0800 (PST) From: Rohan Kollambalath To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Rohan Kollambalath Subject: [PATCH] sysfs:Addresses documentation in sysfs_merge_group and sysfs_unmerge_group. Date: Mon, 12 Feb 2024 08:36:34 +1000 Message-Id: <20240211223634.2103665-1-rohankollambalath@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790643873783663198 X-GMAIL-MSGID: 1790643873783663198 From: Rohan Kollambalath These functions take a struct attribute_group as an input which has an optional .name field. These functions rely on the .name field being populated and do not check if its null. They pass this name into other functions, eventually leading to a null pointer dereference. This change simply updates the documentation of the function to make this requirement clear. Signed-off-by: Rohan Kollambalath --- fs/sysfs/group.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 138676463336..8a22444dd46a 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -318,13 +318,13 @@ void sysfs_remove_groups(struct kobject *kobj, EXPORT_SYMBOL_GPL(sysfs_remove_groups); /** - * sysfs_merge_group - merge files into a pre-existing attribute group. + * sysfs_merge_group - merge files into a pre-existing named attribute group. * @kobj: The kobject containing the group. * @grp: The files to create and the attribute group they belong to. * - * This function returns an error if the group doesn't exist or any of the - * files already exist in that group, in which case none of the new files - * are created. + * This function returns an error if the group doesn't exist, the .name field is + * NULL or any of the files already exist in that group, in which case none of + * the new files are created. */ int sysfs_merge_group(struct kobject *kobj, const struct attribute_group *grp) @@ -356,7 +356,7 @@ int sysfs_merge_group(struct kobject *kobj, EXPORT_SYMBOL_GPL(sysfs_merge_group); /** - * sysfs_unmerge_group - remove files from a pre-existing attribute group. + * sysfs_unmerge_group - remove files from a pre-existing named attribute group. * @kobj: The kobject containing the group. * @grp: The files to remove and the attribute group they belong to. */