diff mbox series

[29/42] drm/selftests/test-drm_dp_mst_helper: Place 'struct drm_dp_sideband_msg_req_body' onto the heap

Message ID 20201116174112.1833368-30-lee.jones@linaro.org
State Accepted
Commit ffefe45a2d9ca4eef4b5fe88bd7a8072cdc94e05
Headers show
Series Rid W=1 warnings from GPU (non-Radeon) | expand

Commit Message

Lee Jones Nov. 16, 2020, 5:40 p.m. UTC
The stack is too full.

Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function ‘sideband_msg_req_encode_decode’:
 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]

Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Lyude Paul <lyude@redhat.com>
Cc: David Francis <David.Francis@amd.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 .../drm/selftests/test-drm_dp_mst_helper.c    | 31 ++++++++++++-------
 1 file changed, 20 insertions(+), 11 deletions(-)

Comments

Lyude Paul Nov. 16, 2020, 8:53 p.m. UTC | #1
Huh-could have sworn I had reviewed this one already.

Reviewed-by: Lyude Paul <lyude@redhat.com>

On Mon, 2020-11-16 at 17:40 +0000, Lee Jones wrote:
> The stack is too full.
> 
> Fixes the following W=1 kernel build warning(s):
> 
>  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function
> ‘sideband_msg_req_encode_decode’:
>  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the
> frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> 
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: David Francis <David.Francis@amd.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  .../drm/selftests/test-drm_dp_mst_helper.c    | 31 ++++++++++++-------
>  1 file changed, 20 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> index 1d696ec001cff..e00bdc557f880 100644
> --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> @@ -120,44 +120,53 @@ sideband_msg_req_equal(const struct
> drm_dp_sideband_msg_req_body *in,
>  static bool
>  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
>  {
> -       struct drm_dp_sideband_msg_req_body out = {0};
> +       struct drm_dp_sideband_msg_req_body *out;
>         struct drm_printer p = drm_err_printer(PREFIX_STR);
>         struct drm_dp_sideband_msg_tx txmsg;
>         int i, ret;
> +       bool result = true;
> +
> +       out = kzalloc(sizeof(*out), GFP_KERNEL);
> +       if (!out)
> +               return false;
>  
>         drm_dp_encode_sideband_req(in, &txmsg);
> -       ret = drm_dp_decode_sideband_req(&txmsg, &out);
> +       ret = drm_dp_decode_sideband_req(&txmsg, out);
>         if (ret < 0) {
>                 drm_printf(&p, "Failed to decode sideband request: %d\n",
>                            ret);
> -               return false;
> +               result = false;
> +               goto out;
>         }
>  
> -       if (!sideband_msg_req_equal(in, &out)) {
> +       if (!sideband_msg_req_equal(in, out)) {
>                 drm_printf(&p, "Encode/decode failed, expected:\n");
>                 drm_dp_dump_sideband_msg_req_body(in, 1, &p);
>                 drm_printf(&p, "Got:\n");
> -               drm_dp_dump_sideband_msg_req_body(&out, 1, &p);
> -               return false;
> +               drm_dp_dump_sideband_msg_req_body(out, 1, &p);
> +               result = false;
> +               goto out;
>         }
>  
>         switch (in->req_type) {
>         case DP_REMOTE_DPCD_WRITE:
> -               kfree(out.u.dpcd_write.bytes);
> +               kfree(out->u.dpcd_write.bytes);
>                 break;
>         case DP_REMOTE_I2C_READ:
> -               for (i = 0; i < out.u.i2c_read.num_transactions; i++)
> -                       kfree(out.u.i2c_read.transactions[i].bytes);
> +               for (i = 0; i < out->u.i2c_read.num_transactions; i++)
> +                       kfree(out->u.i2c_read.transactions[i].bytes);
>                 break;
>         case DP_REMOTE_I2C_WRITE:
> -               kfree(out.u.i2c_write.bytes);
> +               kfree(out->u.i2c_write.bytes);
>                 break;
>         }
>  
>         /* Clear everything but the req_type for the input */
>         memset(&in->u, 0, sizeof(in->u));
>  
> -       return true;
> +out:
> +       kfree(out);
> +       return result;
>  }
>  
>  int igt_dp_mst_sideband_msg_req_decode(void *unused)
Lee Jones Nov. 17, 2020, 8:29 a.m. UTC | #2
On Mon, 16 Nov 2020, Lyude Paul wrote:

> Huh-could have sworn I had reviewed this one already.
> 
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Yes, you're right.

It was masked by the discussion with Ville.  Apologies.

> On Mon, 2020-11-16 at 17:40 +0000, Lee Jones wrote:V
> > The stack is too full.
> > 
> > Fixes the following W=1 kernel build warning(s):
> > 
> >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c: In function
> > ‘sideband_msg_req_encode_decode’:
> >  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:161:1: warning: the
> > frame size of 1176 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > 
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > Cc: Lyude Paul <lyude@redhat.com>
> > Cc: David Francis <David.Francis@amd.com>
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  .../drm/selftests/test-drm_dp_mst_helper.c    | 31 ++++++++++++-------
> >  1 file changed, 20 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
index 1d696ec001cff..e00bdc557f880 100644
--- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
+++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
@@ -120,44 +120,53 @@  sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in,
 static bool
 sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
 {
-	struct drm_dp_sideband_msg_req_body out = {0};
+	struct drm_dp_sideband_msg_req_body *out;
 	struct drm_printer p = drm_err_printer(PREFIX_STR);
 	struct drm_dp_sideband_msg_tx txmsg;
 	int i, ret;
+	bool result = true;
+
+	out = kzalloc(sizeof(*out), GFP_KERNEL);
+	if (!out)
+		return false;
 
 	drm_dp_encode_sideband_req(in, &txmsg);
-	ret = drm_dp_decode_sideband_req(&txmsg, &out);
+	ret = drm_dp_decode_sideband_req(&txmsg, out);
 	if (ret < 0) {
 		drm_printf(&p, "Failed to decode sideband request: %d\n",
 			   ret);
-		return false;
+		result = false;
+		goto out;
 	}
 
-	if (!sideband_msg_req_equal(in, &out)) {
+	if (!sideband_msg_req_equal(in, out)) {
 		drm_printf(&p, "Encode/decode failed, expected:\n");
 		drm_dp_dump_sideband_msg_req_body(in, 1, &p);
 		drm_printf(&p, "Got:\n");
-		drm_dp_dump_sideband_msg_req_body(&out, 1, &p);
-		return false;
+		drm_dp_dump_sideband_msg_req_body(out, 1, &p);
+		result = false;
+		goto out;
 	}
 
 	switch (in->req_type) {
 	case DP_REMOTE_DPCD_WRITE:
-		kfree(out.u.dpcd_write.bytes);
+		kfree(out->u.dpcd_write.bytes);
 		break;
 	case DP_REMOTE_I2C_READ:
-		for (i = 0; i < out.u.i2c_read.num_transactions; i++)
-			kfree(out.u.i2c_read.transactions[i].bytes);
+		for (i = 0; i < out->u.i2c_read.num_transactions; i++)
+			kfree(out->u.i2c_read.transactions[i].bytes);
 		break;
 	case DP_REMOTE_I2C_WRITE:
-		kfree(out.u.i2c_write.bytes);
+		kfree(out->u.i2c_write.bytes);
 		break;
 	}
 
 	/* Clear everything but the req_type for the input */
 	memset(&in->u, 0, sizeof(in->u));
 
-	return true;
+out:
+	kfree(out);
+	return result;
 }
 
 int igt_dp_mst_sideband_msg_req_decode(void *unused)