kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: M Chetan Kumar <m.chetan.kumar@intel.com>
Cc: Intel Corporation <linuxwwan@intel.com>,
	Loic Poulain <loic.poulain@linaro.org>,
	Sergey Ryazanov <ryazanov.s.a@gmail.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH net-next] net: wwan: iosm: fix memory leak in ipc_devlink_create_region()
Date: Wed, 15 Sep 2021 13:35:59 +0300	[thread overview]
Message-ID: <20210915103559.GA7060@kili> (raw)

This doesn't free the first region in devlink->cd_regions[0] so it's a
memory leak.

Fixes: 13bb8429ca98 ("net: wwan: iosm: firmware flashing and coredump collection")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/wwan/iosm/iosm_ipc_devlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wwan/iosm/iosm_ipc_devlink.c b/drivers/net/wwan/iosm/iosm_ipc_devlink.c
index 592792c277fe..6d4f592ba0b6 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_devlink.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_devlink.c
@@ -231,7 +231,7 @@ static int ipc_devlink_create_region(struct iosm_devlink *devlink)
 {
 	struct devlink_region_ops *mdm_coredump;
 	int rc = 0;
-	u8 i;
+	int i;
 
 	mdm_coredump = devlink->iosm_devlink_mdm_coredump;
 	for (i = 0; i < IOSM_NOF_CD_REGION; i++) {
@@ -247,7 +247,7 @@ static int ipc_devlink_create_region(struct iosm_devlink *devlink)
 			rc = PTR_ERR(devlink->cd_regions[i]);
 			dev_err(devlink->dev, "Devlink region fail,err %d", rc);
 			/* Delete previously created regions */
-			for ( ; i > 0; i--)
+			for ( ; i >= 0; i--)
 				devlink_region_destroy(devlink->cd_regions[i]);
 			goto region_create_fail;
 		}
-- 
2.20.1


             reply	other threads:[~2021-09-15 10:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 10:35 Dan Carpenter [this message]
2021-09-15 11:05 ` [PATCH net-next] net: wwan: iosm: fix memory leak in ipc_devlink_create_region() Kumar, M Chetan
2021-09-15 19:58   ` Jakub Kicinski

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=20210915103559.GA7060@kili \
    --to=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=johannes@sipsolutions.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linuxwwan@intel.com \
    --cc=loic.poulain@linaro.org \
    --cc=m.chetan.kumar@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=ryazanov.s.a@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;
as well as URLs for NNTP newsgroup(s).