All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [lee-linaro:tb-fix-w1-warnings 125/232] drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:135 sideband_msg_req_encode_decode() warn: possible memory leak of 'out'
Date: Wed, 11 Nov 2020 13:06:32 +0300	[thread overview]
Message-ID: <20201111100632.GL29398@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 4892 bytes --]

tree:   https://git.linaro.org/people/lee.jones/linux.git tb-fix-w1-warnings
head:   e825caa1d43573f0c17dded446f806064e767e81
commit: 81b681e9f500df49c7b4f7bdea35692ae362701a [125/232] drm/selftests/test-drm_dp_mst_helper: Move 'sideband_msg_req_encode_decode' onto the heap
config: i386-randconfig-m021-20201111 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:135 sideband_msg_req_encode_decode() warn: possible memory leak of 'out'

vim +/out +135 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c

2f015ec6eab6930 Lyude Paul 2019-09-03  120  static bool
2f015ec6eab6930 Lyude Paul 2019-09-03  121  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
2f015ec6eab6930 Lyude Paul 2019-09-03  122  {
fc6e9f1a18159e5 Lee Jones  2020-11-05  123  	struct drm_dp_sideband_msg_req_body *out;
2f015ec6eab6930 Lyude Paul 2019-09-03  124  	struct drm_printer p = drm_err_printer(PREFIX_STR);
81b681e9f500df4 Lee Jones  2020-11-05  125  	struct drm_dp_sideband_msg_tx *txmsg;
2f015ec6eab6930 Lyude Paul 2019-09-03  126  	int i, ret;
fc6e9f1a18159e5 Lee Jones  2020-11-05  127  	bool result = true;
fc6e9f1a18159e5 Lee Jones  2020-11-05  128  
fc6e9f1a18159e5 Lee Jones  2020-11-05  129  	out = kzalloc(sizeof(*out), GFP_KERNEL);
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

fc6e9f1a18159e5 Lee Jones  2020-11-05  130  	if (!out)
fc6e9f1a18159e5 Lee Jones  2020-11-05  131  		return false;
2f015ec6eab6930 Lyude Paul 2019-09-03  132  
81b681e9f500df4 Lee Jones  2020-11-05  133  	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
81b681e9f500df4 Lee Jones  2020-11-05  134  	if (!txmsg)
81b681e9f500df4 Lee Jones  2020-11-05 @135  		return false;
                                                        ^^^^^^^^^^^^^
Leak

81b681e9f500df4 Lee Jones  2020-11-05  136  
81b681e9f500df4 Lee Jones  2020-11-05  137  	drm_dp_encode_sideband_req(in, txmsg);
81b681e9f500df4 Lee Jones  2020-11-05  138  	ret = drm_dp_decode_sideband_req(txmsg, out);
2f015ec6eab6930 Lyude Paul 2019-09-03  139  	if (ret < 0) {
2f015ec6eab6930 Lyude Paul 2019-09-03  140  		drm_printf(&p, "Failed to decode sideband request: %d\n",
2f015ec6eab6930 Lyude Paul 2019-09-03  141  			   ret);
fc6e9f1a18159e5 Lee Jones  2020-11-05  142  		result = false;
fc6e9f1a18159e5 Lee Jones  2020-11-05  143  		goto out;
2f015ec6eab6930 Lyude Paul 2019-09-03  144  	}
2f015ec6eab6930 Lyude Paul 2019-09-03  145  
fc6e9f1a18159e5 Lee Jones  2020-11-05  146  	if (!sideband_msg_req_equal(in, out)) {
2f015ec6eab6930 Lyude Paul 2019-09-03  147  		drm_printf(&p, "Encode/decode failed, expected:\n");
2f015ec6eab6930 Lyude Paul 2019-09-03  148  		drm_dp_dump_sideband_msg_req_body(in, 1, &p);
2f015ec6eab6930 Lyude Paul 2019-09-03  149  		drm_printf(&p, "Got:\n");
fc6e9f1a18159e5 Lee Jones  2020-11-05  150  		drm_dp_dump_sideband_msg_req_body(out, 1, &p);
fc6e9f1a18159e5 Lee Jones  2020-11-05  151  		result = false;
fc6e9f1a18159e5 Lee Jones  2020-11-05  152  		goto out;
2f015ec6eab6930 Lyude Paul 2019-09-03  153  	}
2f015ec6eab6930 Lyude Paul 2019-09-03  154  
2f015ec6eab6930 Lyude Paul 2019-09-03  155  	switch (in->req_type) {
2f015ec6eab6930 Lyude Paul 2019-09-03  156  	case DP_REMOTE_DPCD_WRITE:
fc6e9f1a18159e5 Lee Jones  2020-11-05  157  		kfree(out->u.dpcd_write.bytes);
2f015ec6eab6930 Lyude Paul 2019-09-03  158  		break;
2f015ec6eab6930 Lyude Paul 2019-09-03  159  	case DP_REMOTE_I2C_READ:
fc6e9f1a18159e5 Lee Jones  2020-11-05  160  		for (i = 0; i < out->u.i2c_read.num_transactions; i++)
fc6e9f1a18159e5 Lee Jones  2020-11-05  161  			kfree(out->u.i2c_read.transactions[i].bytes);
2f015ec6eab6930 Lyude Paul 2019-09-03  162  		break;
2f015ec6eab6930 Lyude Paul 2019-09-03  163  	case DP_REMOTE_I2C_WRITE:
fc6e9f1a18159e5 Lee Jones  2020-11-05  164  		kfree(out->u.i2c_write.bytes);
2f015ec6eab6930 Lyude Paul 2019-09-03  165  		break;
2f015ec6eab6930 Lyude Paul 2019-09-03  166  	}
2f015ec6eab6930 Lyude Paul 2019-09-03  167  
2f015ec6eab6930 Lyude Paul 2019-09-03  168  	/* Clear everything but the req_type for the input */
2f015ec6eab6930 Lyude Paul 2019-09-03  169  	memset(&in->u, 0, sizeof(in->u));
2f015ec6eab6930 Lyude Paul 2019-09-03  170  
fc6e9f1a18159e5 Lee Jones  2020-11-05  171  out:
fc6e9f1a18159e5 Lee Jones  2020-11-05  172  	kfree(out);
81b681e9f500df4 Lee Jones  2020-11-05  173  	kfree(txmsg);
fc6e9f1a18159e5 Lee Jones  2020-11-05  174  	return result;
2f015ec6eab6930 Lyude Paul 2019-09-03  175  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35092 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [lee-linaro:tb-fix-w1-warnings 125/232] drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:135 sideband_msg_req_encode_decode() warn: possible memory leak of 'out'
Date: Wed, 11 Nov 2020 13:06:32 +0300	[thread overview]
Message-ID: <20201111100632.GL29398@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 4892 bytes --]

tree:   https://git.linaro.org/people/lee.jones/linux.git tb-fix-w1-warnings
head:   e825caa1d43573f0c17dded446f806064e767e81
commit: 81b681e9f500df49c7b4f7bdea35692ae362701a [125/232] drm/selftests/test-drm_dp_mst_helper: Move 'sideband_msg_req_encode_decode' onto the heap
config: i386-randconfig-m021-20201111 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:135 sideband_msg_req_encode_decode() warn: possible memory leak of 'out'

vim +/out +135 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c

2f015ec6eab6930 Lyude Paul 2019-09-03  120  static bool
2f015ec6eab6930 Lyude Paul 2019-09-03  121  sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
2f015ec6eab6930 Lyude Paul 2019-09-03  122  {
fc6e9f1a18159e5 Lee Jones  2020-11-05  123  	struct drm_dp_sideband_msg_req_body *out;
2f015ec6eab6930 Lyude Paul 2019-09-03  124  	struct drm_printer p = drm_err_printer(PREFIX_STR);
81b681e9f500df4 Lee Jones  2020-11-05  125  	struct drm_dp_sideband_msg_tx *txmsg;
2f015ec6eab6930 Lyude Paul 2019-09-03  126  	int i, ret;
fc6e9f1a18159e5 Lee Jones  2020-11-05  127  	bool result = true;
fc6e9f1a18159e5 Lee Jones  2020-11-05  128  
fc6e9f1a18159e5 Lee Jones  2020-11-05  129  	out = kzalloc(sizeof(*out), GFP_KERNEL);
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

fc6e9f1a18159e5 Lee Jones  2020-11-05  130  	if (!out)
fc6e9f1a18159e5 Lee Jones  2020-11-05  131  		return false;
2f015ec6eab6930 Lyude Paul 2019-09-03  132  
81b681e9f500df4 Lee Jones  2020-11-05  133  	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
81b681e9f500df4 Lee Jones  2020-11-05  134  	if (!txmsg)
81b681e9f500df4 Lee Jones  2020-11-05 @135  		return false;
                                                        ^^^^^^^^^^^^^
Leak

81b681e9f500df4 Lee Jones  2020-11-05  136  
81b681e9f500df4 Lee Jones  2020-11-05  137  	drm_dp_encode_sideband_req(in, txmsg);
81b681e9f500df4 Lee Jones  2020-11-05  138  	ret = drm_dp_decode_sideband_req(txmsg, out);
2f015ec6eab6930 Lyude Paul 2019-09-03  139  	if (ret < 0) {
2f015ec6eab6930 Lyude Paul 2019-09-03  140  		drm_printf(&p, "Failed to decode sideband request: %d\n",
2f015ec6eab6930 Lyude Paul 2019-09-03  141  			   ret);
fc6e9f1a18159e5 Lee Jones  2020-11-05  142  		result = false;
fc6e9f1a18159e5 Lee Jones  2020-11-05  143  		goto out;
2f015ec6eab6930 Lyude Paul 2019-09-03  144  	}
2f015ec6eab6930 Lyude Paul 2019-09-03  145  
fc6e9f1a18159e5 Lee Jones  2020-11-05  146  	if (!sideband_msg_req_equal(in, out)) {
2f015ec6eab6930 Lyude Paul 2019-09-03  147  		drm_printf(&p, "Encode/decode failed, expected:\n");
2f015ec6eab6930 Lyude Paul 2019-09-03  148  		drm_dp_dump_sideband_msg_req_body(in, 1, &p);
2f015ec6eab6930 Lyude Paul 2019-09-03  149  		drm_printf(&p, "Got:\n");
fc6e9f1a18159e5 Lee Jones  2020-11-05  150  		drm_dp_dump_sideband_msg_req_body(out, 1, &p);
fc6e9f1a18159e5 Lee Jones  2020-11-05  151  		result = false;
fc6e9f1a18159e5 Lee Jones  2020-11-05  152  		goto out;
2f015ec6eab6930 Lyude Paul 2019-09-03  153  	}
2f015ec6eab6930 Lyude Paul 2019-09-03  154  
2f015ec6eab6930 Lyude Paul 2019-09-03  155  	switch (in->req_type) {
2f015ec6eab6930 Lyude Paul 2019-09-03  156  	case DP_REMOTE_DPCD_WRITE:
fc6e9f1a18159e5 Lee Jones  2020-11-05  157  		kfree(out->u.dpcd_write.bytes);
2f015ec6eab6930 Lyude Paul 2019-09-03  158  		break;
2f015ec6eab6930 Lyude Paul 2019-09-03  159  	case DP_REMOTE_I2C_READ:
fc6e9f1a18159e5 Lee Jones  2020-11-05  160  		for (i = 0; i < out->u.i2c_read.num_transactions; i++)
fc6e9f1a18159e5 Lee Jones  2020-11-05  161  			kfree(out->u.i2c_read.transactions[i].bytes);
2f015ec6eab6930 Lyude Paul 2019-09-03  162  		break;
2f015ec6eab6930 Lyude Paul 2019-09-03  163  	case DP_REMOTE_I2C_WRITE:
fc6e9f1a18159e5 Lee Jones  2020-11-05  164  		kfree(out->u.i2c_write.bytes);
2f015ec6eab6930 Lyude Paul 2019-09-03  165  		break;
2f015ec6eab6930 Lyude Paul 2019-09-03  166  	}
2f015ec6eab6930 Lyude Paul 2019-09-03  167  
2f015ec6eab6930 Lyude Paul 2019-09-03  168  	/* Clear everything but the req_type for the input */
2f015ec6eab6930 Lyude Paul 2019-09-03  169  	memset(&in->u, 0, sizeof(in->u));
2f015ec6eab6930 Lyude Paul 2019-09-03  170  
fc6e9f1a18159e5 Lee Jones  2020-11-05  171  out:
fc6e9f1a18159e5 Lee Jones  2020-11-05  172  	kfree(out);
81b681e9f500df4 Lee Jones  2020-11-05  173  	kfree(txmsg);
fc6e9f1a18159e5 Lee Jones  2020-11-05  174  	return result;
2f015ec6eab6930 Lyude Paul 2019-09-03  175  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35092 bytes --]

             reply	other threads:[~2020-11-11 10:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 10:06 Dan Carpenter [this message]
2020-11-11 10:06 ` [lee-linaro:tb-fix-w1-warnings 125/232] drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c:135 sideband_msg_req_encode_decode() warn: possible memory leak of 'out' Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2020-11-11  7:05 kernel test robot

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=20201111100632.GL29398@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.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 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.