All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Chengfeng Ye <dg573847474@gmail.com>,
	"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jack Wang <jinpu.wang@cloud.ionos.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: pm8001: Fix data race in sysfs SAS address read
Date: Thu, 15 Jan 2026 09:24:34 -0800	[thread overview]
Message-ID: <2c210e30-e7bd-4b70-ad4e-cc7a1bbb5309@acm.org> (raw)
In-Reply-To: <20260115171140.281969-1-cyeaa@connect.ust.hk>

On 1/15/26 9:11 AM, Chengfeng Ye wrote:
> diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
> index cbfda8c04e95..e49f11969b3b 100644
> --- a/drivers/scsi/pm8001/pm8001_ctl.c
> +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> @@ -311,8 +311,15 @@ static ssize_t pm8001_ctl_host_sas_address_show(struct device *cdev,
>   	struct Scsi_Host *shost = class_to_shost(cdev);
>   	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
>   	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> -	return sysfs_emit(buf, "0x%016llx\n",
> -			be64_to_cpu(*(__be64 *)pm8001_ha->sas_addr));
> +	unsigned long flags;
> +	ssize_t ret;
> +
> +	spin_lock_irqsave(&pm8001_ha->lock, flags);
> +	ret = sysfs_emit(buf, "0x%016llx\n",
> +			 be64_to_cpu(*(__be64 *)pm8001_ha->sas_addr));
> +	spin_unlock_irqrestore(&pm8001_ha->lock, flags);
> +
> +	return ret;
>   }
>   static DEVICE_ATTR(host_sas_address, S_IRUGO,
>   		   pm8001_ctl_host_sas_address_show, NULL);

Why isn't READ_ONCE() sufficient? And why explicit spin_lock_irqsave() 
and spin_unlock_irqrestore() calls instead of using scoped_guard()?

Bart.

  reply	other threads:[~2026-01-15 17:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 17:11 [PATCH] scsi: pm8001: Fix data race in sysfs SAS address read Chengfeng Ye
2026-01-15 17:24 ` Bart Van Assche [this message]
2026-01-15 17:57   ` Chengfeng Ye
2026-01-15 18:52   ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c210e30-e7bd-4b70-ad4e-cc7a1bbb5309@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=dg573847474@gmail.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.