From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 22B6C30F533 for ; Thu, 21 May 2026 11:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779364746; cv=none; b=rpw3QQCzxXM0G6nHaj2Ko8SPXy8GtmslIhdSOm8lhL2lUFNEuedttewyRAS5NCrREgRC1Mtzx2UnrT3HY/i/pZHWMz1PyqT3oY2W05dcAofNuJnYgFHSgvwQpvCNgeqy4fPwgAMAPj1Lg2whndsgCtW8ugWa5lIljVbAGfGfDjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779364746; c=relaxed/simple; bh=9QNDz0SiTVVe4NXAzmtAyUk/+gd+KBofCbP69W8PMH4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=u6LUdlBYzBe3uu63n40KCwrN0M6Pw0ZQV2APXvSc1gvjawzd5wTftEVLKOfZi4akurvdYNG3BkhufVVpQqO5JZAoV2Obbj4TWrZhlZSJzQ2CNfvcK8n04EjwN9u9ojvR6tQT8i3UMJMZAYG2RCH4LDvXLtBZ3MjuPYQY/x2Nu8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-3695bf7d082so5419044a91.0 for ; Thu, 21 May 2026 04:59:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779364744; x=1779969544; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h0n/yoOj7r3WTChH1iCOeo3b0bKG1oOEOnSnWhVWyhQ=; b=n1HpXVxuyT7eXJVtlB9FdSkwWYSAVi3sYV1R0jPcoINPQVZLq31RSGgFROMWrM9Vvl tW2rNJ+PEEfcbc61afQ3LVlLqzDPJ8QWtUAS5cq9lrQ/csgBhuDomLFehJdmV8hhs9pd i3iZZ335VygAqPV9ApQqyONueNhhibFPUvjYfsgtJwIYUBYewBXzsPjoAZOK2O/UC9Ho XEtv6ErS+8uZ1dK4K5eGsZXUO8eej+BS4vHxqhWhVbtiThDKLwSRNydFcByLgJKaqcnq VDjnBSzgLs1HYH/+xsIKk9lIpzbzHcECF1pQoxEZX11N2j6N8WKgG5vjDzJgHK/lywHz bgRg== X-Forwarded-Encrypted: i=1; AFNElJ/z7FEGADFkCfQ+jqcJ15ne+D2F0a3LXLu6ZQYh9bbwG2QElpMC2wUf+Ha+Gqo+JaNTvbcBFgfG2KTGfb8=@vger.kernel.org X-Gm-Message-State: AOJu0YzAzQFXDwYPxHEY1v0HtLgyAQ+XmBJBItc5GHbRGtqBa0qVoMd8 U5pwvtHexM467wTYlR28mS6JKah0NrdSoTqfZ55qonrLjJsf8bQGFdCc X-Gm-Gg: Acq92OEXJVDIz1rxAoaHJU8Q7dEoDbcAt7Jyy8WrhXiR7dlxj5Kseqa1/pwaHf4l9ni pmMQeDXwuiWy8qeSBHGOzh+Ee/2DvXHeNbpYVZv5ntc9fOfAXRQqT/Kg2Vd9HsrNyqCK6/pLRxV q3lGNKwCJs2F3g6TKjD6Dvda89bZxyb6eX3wrrXmt4VtuE5TZF3cubKV3OV17kHtTfEHZzTkSDJ x2eoCui/U8mVFSVJxQLLpiqtJSIaA4021RTvbyOgBbpmSMsan8HP8nV/+JWgEwL2tggniwWkHAt S2fZ5Dq+hF+9pbICNx2Hv+xM1XQVocVza/ee8s6us/fb9yZzLJwzNQr7oBQORQ6/IJ2DHoWQcSW M9A+gkvD+GQIEW/RHW6ofgHKBCnotRs4Jnp4uI2bFUq++qKI9MQTehmFJuYp6f0NfhcR8IDLf8z liSlOeqo48W1AaL+vSZS9pcVpkvIIoatt2a7+f+WjshUp4J7uMTKPnTW2HNI9c7RXBh39x/i/gx 76Da5immJuZhDl4SrSPKIzA4QcLkTpqHeUP0Y3Q7nIRhuvhbBbt5BcEdHNAz7TNkT9ScyuXiRew ukkKWW/SQJJDUhVn47RJSpOplymrMdQIy+THyhfveQ== X-Received: by 2002:a17:90b:2d43:b0:369:a74b:28cc with SMTP id 98e67ed59e1d1-36a45c7ef23mr2530942a91.18.1779364744399; Thu, 21 May 2026 04:59:04 -0700 (PDT) Received: from localhost (fpd11144dd.ap.nuro.jp. [209.17.68.221]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a440491a9sm751306a91.0.2026.05.21.04.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 04:59:03 -0700 (PDT) Date: Thu, 21 May 2026 20:59:02 +0900 From: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= To: Gianfranco Dutka Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI/sysfs: NULL res_attr slot after kfree as defence against double-remove Message-ID: <20260521115433.GB647881@rocinante> References: <20260520211306.3301893-1-gianfranco.dutka@arista.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260520211306.3301893-1-gianfranco.dutka@arista.com> Hello, > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -1228,11 +1228,13 @@ static void pci_remove_resource_files(struct pci_dev *pdev) > if (res_attr) { > sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); > kfree(res_attr); > + pdev->res_attr[i] = NULL; > } > > res_attr = pdev->res_attr_wc[i]; > if (res_attr) { > sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); > kfree(res_attr); > + pdev->res_attr_wc[i] = NULL; > } > } > } Similar such patches (for reference): - https://lore.kernel.org/linux-pci/20251010093023.2569-1-guojinhui.liam@bytedance.com/ - https://lore.kernel.org/linux-pci/20250629030547.1073425-1-zhangjian496@huawei.com/ - https://lore.kernel.org/linux-pci/20210507102706.7658-1-danijel.slivka@amd.com/ - https://lore.kernel.org/linux-pci/20191024172157.878735-2-s.miroshnichenko@yadro.com/ Thank you! Krzysztof