public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben.hutchings@codethink.co.uk>
To: Arnd Bergmann <arnd@arndb.de>,
	Anil Gurumurthy <anil.gurumurthy@qlogic.com>,
	Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>,
	"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: hare@suse.com, linux-scsi@vger.kernel.org,
	y2038@lists.linaro.org, linux-kernel@vger.kernel.org,
	jthumshirn@suse.de, hch@lst.de
Subject: Re: [Y2038] [PATCH 3/7] scsi: bfa: improve bfa_ioc_send_enable/disable data
Date: Mon, 13 Nov 2017 14:08:34 +0000	[thread overview]
Message-ID: <1510582114.18523.3.camel@codethink.co.uk> (raw)
In-Reply-To: <20171110153715.1929456-4-arnd@arndb.de>

On Fri, 2017-11-10 at 16:37 +0100, Arnd Bergmann wrote:
> In bfa_ioc_send_enable, we use the deprecated do_gettimeofday() function
> to read the current time. This is not a problem, since the firmware
> interface is already limited to 32-bit timestamps, but it's better
> to use ktime_get_seconds() and document what the limitation is.
> 
> I noticed that I did the same change in commit a5af83925363 ("bna:
> avoid writing uninitialized data into hw registers") for the ethernet
> driver. That commit also changed the "disable" funtion to initialize
> the data we pass to the firmware properly, so I'm doing the same
> thing here.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/scsi/bfa/bfa_ioc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
> index 256f4afaccf9..117332537763 100644
> --- a/drivers/scsi/bfa/bfa_ioc.c
> +++ b/drivers/scsi/bfa/bfa_ioc.c
> @@ -1809,13 +1809,12 @@ static void
>  bfa_ioc_send_enable(struct bfa_ioc_s *ioc)
>  {
>  	struct bfi_ioc_ctrl_req_s enable_req;
> -	struct timeval tv;
>  
>  	bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ,
>  		    bfa_ioc_portid(ioc));
>  	enable_req.clscode = cpu_to_be16(ioc->clscode);
> -	do_gettimeofday(&tv);
> -	enable_req.tv_sec = be32_to_cpu(tv.tv_sec);
> +	/* unsigned 32-bit time_t overflow in y2106 */
> +	enable_req.tv_sec = be32_to_cpu(ktime_get_real_seconds());

The byte order conversion should also logically be cpu_to_be32(), not
be32_to_cpu().

Ben.

>  	bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req_s));
>  }
>  
> @@ -1826,6 +1825,9 @@ bfa_ioc_send_disable(struct bfa_ioc_s *ioc)
>  
>  	bfi_h2i_set(disable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_DISABLE_REQ,
>  		    bfa_ioc_portid(ioc));
> +	disable_req.clscode = cpu_to_be16(ioc->clscode);
> +	/* unsigned 32-bit time_t overflow in y2106 */
> +	disable_req.tv_sec = be32_to_cpu(ktime_get_real_seconds());
>  	bfa_ioc_mbox_send(ioc, &disable_req, sizeof(struct bfi_ioc_ctrl_req_s));
>  }
>  
-- 
Ben Hutchings
Software Developer, Codethink Ltd.

  reply	other threads:[~2017-11-13 14:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 15:37 [PATCH 0/7] scsi: bfa: do_gettimeofday removal Arnd Bergmann
2017-11-10 15:37 ` [PATCH 1/7] scsi: bfa: use ktime_get_real_ts64 for firmware timestamp Arnd Bergmann
2017-11-10 15:37 ` [PATCH 2/7] scsi: bfa: use proper time accessor for stats_reset_time Arnd Bergmann
2017-11-10 15:37 ` [PATCH 3/7] scsi: bfa: improve bfa_ioc_send_enable/disable data Arnd Bergmann
2017-11-13 14:08   ` Ben Hutchings [this message]
2017-11-13 14:55     ` [Y2038] " Arnd Bergmann
2017-11-10 15:37 ` [PATCH 4/7] scsi: bfa: document overflow of io_profile_start_time Arnd Bergmann
2017-11-10 15:37 ` [PATCH 5/7] scsi: bfa: replace bfa_get_log_time() with ktime_get_real_seconds() Arnd Bergmann
2017-11-10 15:37 ` [PATCH 6/7] scsi: bfa: try to sanitize vendor netlink events Arnd Bergmann
2017-11-10 15:37 ` [PATCH 7/7] scsi: bfa: use 64-bit times in bfa_aen_entry_s ABI Arnd Bergmann
2017-11-10 17:24 ` [PATCH 0/7] scsi: bfa: do_gettimeofday removal Christoph Hellwig
2017-11-10 17:33   ` Gurumurthy, Anil
2017-11-21  3:04 ` Martin K. Petersen

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=1510582114.18523.3.camel@codethink.co.uk \
    --to=ben.hutchings@codethink.co.uk \
    --cc=anil.gurumurthy@qlogic.com \
    --cc=arnd@arndb.de \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sudarsana.kalluru@qlogic.com \
    --cc=y2038@lists.linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox