mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.com>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] tty: rocket: reduce stack usage
Date: Mon, 21 Oct 2019 07:59:55 +0200	[thread overview]
Message-ID: <afe485c6-7816-96dd-f301-1c0797e8b7ce@suse.com> (raw)
In-Reply-To: <20191018161712.27807-1-sudipm.mukherjee@gmail.com>

On 18. 10. 19, 18:17, Sudip Mukherjee wrote:
> The build of xtensa allmodconfig gives warning of:
> In function 'get_ports.isra.0':
> warning: the frame size of 1040 bytes is larger than 1024 bytes
> 
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>

Acked-by: Jiri Slaby <jslaby@suse.cz>

Thanks.

> v2: check faliure of kzalloc
> 
>  drivers/tty/rocket.c | 32 +++++++++++++++++++-------------
>  1 file changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
> index 5ba6816ebf81..fbaa4ec85560 100644
> --- a/drivers/tty/rocket.c
> +++ b/drivers/tty/rocket.c
> @@ -1222,22 +1222,28 @@ static int set_config(struct tty_struct *tty, struct r_port *info,
>   */
>  static int get_ports(struct r_port *info, struct rocket_ports __user *retports)
>  {
> -	struct rocket_ports tmp;
> -	int board;
> +	struct rocket_ports *tmp;
> +	int board, ret = 0;
>  
> -	memset(&tmp, 0, sizeof (tmp));
> -	tmp.tty_major = rocket_driver->major;
> +	tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
> +	if (!tmp)
> +		return -ENOMEM;
> +
> +	tmp->tty_major = rocket_driver->major;
>  
>  	for (board = 0; board < 4; board++) {
> -		tmp.rocketModel[board].model = rocketModel[board].model;
> -		strcpy(tmp.rocketModel[board].modelString, rocketModel[board].modelString);
> -		tmp.rocketModel[board].numPorts = rocketModel[board].numPorts;
> -		tmp.rocketModel[board].loadrm2 = rocketModel[board].loadrm2;
> -		tmp.rocketModel[board].startingPortNumber = rocketModel[board].startingPortNumber;
> -	}
> -	if (copy_to_user(retports, &tmp, sizeof (*retports)))
> -		return -EFAULT;
> -	return 0;
> +		tmp->rocketModel[board].model = rocketModel[board].model;
> +		strcpy(tmp->rocketModel[board].modelString,
> +		       rocketModel[board].modelString);
> +		tmp->rocketModel[board].numPorts = rocketModel[board].numPorts;
> +		tmp->rocketModel[board].loadrm2 = rocketModel[board].loadrm2;
> +		tmp->rocketModel[board].startingPortNumber =
> +			rocketModel[board].startingPortNumber;
> +	}
> +	if (copy_to_user(retports, tmp, sizeof(*retports)))
> +		ret = -EFAULT;
> +	kfree(tmp);
> +	return ret;
>  }
>  
>  static int reset_rm2(struct r_port *info, void __user *arg)
> 


-- 
js
suse labs

      reply	other threads:[~2019-10-21  6:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 16:17 Sudip Mukherjee
2019-10-21  5:59 ` Jiri Slaby [this message]

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=afe485c6-7816-96dd-f301-1c0797e8b7ce@suse.com \
    --to=jslaby@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudipm.mukherjee@gmail.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

all inboxes | Powered by JetHome®