From: Dan Carpenter <dan.carpenter@oracle.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Chen-Yu Tsai <wens@csie.org>,
Hans-Christian Egtvedt <egtvedt@samfundet.no>,
Rob Herring <robh@kernel.org>,
Krzysztof Adamski <krzysztof.adamski@tieto.com>,
Laxman Dewangan <ldewangan@nvidia.com>,
Hans de Goede <hdegoede@redhat.com>,
linux-gpio@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] pinctrl: sunxi: Testing the wrong variable
Date: Fri, 18 Nov 2016 14:35:57 +0300 [thread overview]
Message-ID: <20161118113557.GA3281@mwanda> (raw)
Smatch complains that we dereference "map" before testing it for NULL
which is true. We should be testing "*map" instead. Also on the error
path, we should free *map and set it to NULL.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 2339d47..5b0acba 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -398,13 +398,14 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
* map array
*/
*map = krealloc(*map, i * sizeof(struct pinctrl_map), GFP_KERNEL);
- if (!map)
+ if (!*map)
return -ENOMEM;
return 0;
err_free_map:
- kfree(map);
+ kfree(*map);
+ *map = NULL;
return ret;
}
next reply other threads:[~2016-11-18 11:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-18 11:35 Dan Carpenter [this message]
2016-11-18 13:18 ` [patch] pinctrl: sunxi: Testing the wrong variable Maxime Ripard
2016-11-22 8:56 ` Linus Walleij
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=20161118113557.GA3281@mwanda \
--to=dan.carpenter@oracle.com \
--cc=egtvedt@samfundet.no \
--cc=hdegoede@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=krzysztof.adamski@tieto.com \
--cc=ldewangan@nvidia.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=robh@kernel.org \
--cc=wens@csie.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 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).