linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Arnd Bergmann <arnd@arndb.de>, Hannes Reinecke <hare@kernel.org>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: myrs: avoid stack overflow warning
Date: Sat, 3 Nov 2018 09:47:34 +0100	[thread overview]
Message-ID: <c4e5b45e-85a5-d279-0265-a4974f41fa85@suse.de> (raw)
In-Reply-To: <20181102154426.1951776-1-arnd@arndb.de>

On 11/2/18 4:44 PM, Arnd Bergmann wrote:
> Putting a 1024 byte data structure on the stack is generally a bad idea.
> On 32-bit systems, it also triggers a compile-time warning when building
> with -Og:
> 
> drivers/scsi/myrs.c: In function 'myrs_get_ctlr_info':
> drivers/scsi/myrs.c:212:1: error: the frame size of 1028 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
> 
> We only really need three members of the structure, so just read them
> manually here instead of copying the entire structure.
> 
> Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/scsi/myrs.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
> index 0264a2e2bc19..b8d54ef8cf6d 100644
> --- a/drivers/scsi/myrs.c
> +++ b/drivers/scsi/myrs.c
> @@ -163,9 +163,12 @@ static unsigned char myrs_get_ctlr_info(struct myrs_hba *cs)
>   	dma_addr_t ctlr_info_addr;
>   	union myrs_sgl *sgl;
>   	unsigned char status;
> -	struct myrs_ctlr_info old;
> +	unsigned short ldev_present, ldev_critical, ldev_offline;
> +
> +	ldev_present = cs->ctlr_info->ldev_present;
> +	ldev_critical = cs->ctlr_info->ldev_critical;
> +	ldev_offline = cs->ctlr_info->ldev_offline;
>   
> -	memcpy(&old, cs->ctlr_info, sizeof(struct myrs_ctlr_info));
>   	ctlr_info_addr = dma_map_single(&cs->pdev->dev, cs->ctlr_info,
>   					sizeof(struct myrs_ctlr_info),
>   					DMA_FROM_DEVICE);
> @@ -198,9 +201,9 @@ static unsigned char myrs_get_ctlr_info(struct myrs_hba *cs)
>   		    cs->ctlr_info->rbld_active +
>   		    cs->ctlr_info->exp_active != 0)
>   			cs->needs_update = true;
> -		if (cs->ctlr_info->ldev_present != old.ldev_present ||
> -		    cs->ctlr_info->ldev_critical != old.ldev_critical ||
> -		    cs->ctlr_info->ldev_offline != old.ldev_offline)
> +		if (cs->ctlr_info->ldev_present != ldev_present ||
> +		    cs->ctlr_info->ldev_critical != ldev_critical ||
> +		    cs->ctlr_info->ldev_offline != ldev_offline)
>   			shost_printk(KERN_INFO, cs->host,
>   				     "Logical drive count changes (%d/%d/%d)\n",
>   				     cs->ctlr_info->ldev_critical,
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes

  reply	other threads:[~2018-11-03  8:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-02 15:44 [PATCH] scsi: myrs: avoid stack overflow warning Arnd Bergmann
2018-11-03  8:47 ` Hannes Reinecke [this message]
2018-11-06  3:36 ` 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=c4e5b45e-85a5-d279-0265-a4974f41fa85@suse.de \
    --to=hare@suse.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=arnd@arndb.de \
    --cc=hare@kernel.org \
    --cc=jejb@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).