From: Madalin Bucur <madalin.bucur@nxp.com>
To: Florinel Iordache <florinel.iordache@nxp.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH net 4/5] fsl/fman: check dereferencing null pointer
Date: Fri, 31 Jul 2020 07:48:34 +0000 [thread overview]
Message-ID: <AM6PR04MB397680E5084359739F2FC08EEC4E0@AM6PR04MB3976.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <1596177969-27645-5-git-send-email-florinel.iordache@nxp.com>
> -----Original Message-----
> From: Florinel Iordache <florinel.iordache@nxp.com>
> Sent: 31 July 2020 09:46
> To: Madalin Bucur <madalin.bucur@nxp.com>; davem@davemloft.net;
> kuba@kernel.org; netdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; Florinel Iordache
> <florinel.iordache@nxp.com>
> Subject: [PATCH net 4/5] fsl/fman: check dereferencing null pointer
>
> Add a safe check to avoid dereferencing null pointer
>
> Fixes: 57ba4c9b ("fsl/fman: Add FMan MAC support")
>
> Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
> ---
> drivers/net/ethernet/freescale/fman/fman_dtsec.c | 4 ++--
> drivers/net/ethernet/freescale/fman/fman_memac.c | 3 ++-
> drivers/net/ethernet/freescale/fman/fman_tgec.c | 2 +-
> 3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> index 004c266..bce3c93 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> @@ -1200,7 +1200,7 @@ int dtsec_del_hash_mac_address(struct fman_mac
> *dtsec, enet_addr_t *eth_addr)
> list_for_each(pos,
> &dtsec->multicast_addr_hash->lsts[bucket]) {
> hash_entry = ETH_HASH_ENTRY_OBJ(pos);
> - if (hash_entry->addr == addr) {
> + if (hash_entry && hash_entry->addr == addr) {
> list_del_init(&hash_entry->node);
> kfree(hash_entry);
> break;
> @@ -1213,7 +1213,7 @@ int dtsec_del_hash_mac_address(struct fman_mac
> *dtsec, enet_addr_t *eth_addr)
> list_for_each(pos,
> &dtsec->unicast_addr_hash->lsts[bucket]) {
> hash_entry = ETH_HASH_ENTRY_OBJ(pos);
> - if (hash_entry->addr == addr) {
> + if (hash_entry && hash_entry->addr == addr) {
> list_del_init(&hash_entry->node);
> kfree(hash_entry);
> break;
> diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c
> b/drivers/net/ethernet/freescale/fman/fman_memac.c
> index bb02b37..52ee982 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_memac.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
> @@ -852,6 +852,7 @@ int memac_set_tx_pause_frames(struct fman_mac *memac,
> u8 priority,
>
> tmp = ioread32be(®s->command_config);
> tmp &= ~CMD_CFG_PFC_MODE;
> + priority = 0;
This line seems to be added by mistake.
>
> iowrite32be(tmp, ®s->command_config);
>
> @@ -981,7 +982,7 @@ int memac_del_hash_mac_address(struct fman_mac *memac,
> enet_addr_t *eth_addr)
>
> list_for_each(pos, &memac->multicast_addr_hash->lsts[hash]) {
> hash_entry = ETH_HASH_ENTRY_OBJ(pos);
> - if (hash_entry->addr == addr) {
> + if (hash_entry && hash_entry->addr == addr) {
> list_del_init(&hash_entry->node);
> kfree(hash_entry);
> break;
> diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c
> b/drivers/net/ethernet/freescale/fman/fman_tgec.c
> index 8c7eb87..41946b1 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
> @@ -626,7 +626,7 @@ int tgec_del_hash_mac_address(struct fman_mac *tgec,
> enet_addr_t *eth_addr)
>
> list_for_each(pos, &tgec->multicast_addr_hash->lsts[hash]) {
> hash_entry = ETH_HASH_ENTRY_OBJ(pos);
> - if (hash_entry->addr == addr) {
> + if (hash_entry && hash_entry->addr == addr) {
> list_del_init(&hash_entry->node);
> kfree(hash_entry);
> break;
> --
> 1.9.1
next prev parent reply other threads:[~2020-07-31 7:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 6:46 [PATCH net 0/5] DPAA FMan driver fixes Florinel Iordache
2020-07-31 6:46 ` [PATCH net 1/5] fsl/fman: use 32-bit unsigned integer Florinel Iordache
2020-07-31 6:46 ` [PATCH net 2/5] fsl/fman: fix dereference null return value Florinel Iordache
2020-07-31 6:46 ` [PATCH net 3/5] fsl/fman: fix unreachable code Florinel Iordache
2020-07-31 6:46 ` [PATCH net 4/5] fsl/fman: check dereferencing null pointer Florinel Iordache
2020-07-31 7:48 ` Madalin Bucur [this message]
2020-07-31 6:46 ` [PATCH net 5/5] fsl/fman: fix eth hash table allocation Florinel Iordache
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=AM6PR04MB397680E5084359739F2FC08EEC4E0@AM6PR04MB3976.eurprd04.prod.outlook.com \
--to=madalin.bucur@nxp.com \
--cc=davem@davemloft.net \
--cc=florinel.iordache@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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).