All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: nbd@nbd.name
Cc: linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org
Subject: [bug report] mt76: implement functions to get the response skb for MCU calls
Date: Fri, 8 Oct 2021 16:00:07 +0300	[thread overview]
Message-ID: <20211008130007.GA23161@kili> (raw)

Hello Felix Fietkau,

The patch ae5ad6272d25: "mt76: implement functions to get the
response skb for MCU calls" from Sep 30, 2020, leads to the following
Smatch static checker warning:

	drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:1151 mt7921_mcu_get_eeprom()
	error: potentially dereferencing uninitialized 'skb'.

drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
    1136 int mt7921_mcu_get_eeprom(struct mt7921_dev *dev, u32 offset)
    1137 {
    1138         struct mt7921_mcu_eeprom_info req = {
    1139                 .addr = cpu_to_le32(round_down(offset, 16)),
    1140         };
    1141         struct mt7921_mcu_eeprom_info *res;
    1142         struct sk_buff *skb;
    1143         int ret;
    1144         u8 *buf;
    1145 
    1146         ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_ACCESS, &req,
    1147                                         sizeof(req), true, &skb);

If mt76_mcu_send_and_get_msg() calls the dev->mcu_ops->mcu_send_msg()
then "skb" is not initialized.

    1148         if (ret)
    1149                 return ret;
    1150 
--> 1151         res = (struct mt7921_mcu_eeprom_info *)skb->data;
    1152         buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
    1153         memcpy(buf, res->data, 16);
    1154         dev_kfree_skb(skb);
    1155 
    1156         return 0;
    1157 }

regards,
dan carpenter

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: nbd@nbd.name
Cc: linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org
Subject: [bug report] mt76: implement functions to get the response skb for MCU calls
Date: Fri, 8 Oct 2021 16:00:07 +0300	[thread overview]
Message-ID: <20211008130007.GA23161@kili> (raw)

Hello Felix Fietkau,

The patch ae5ad6272d25: "mt76: implement functions to get the
response skb for MCU calls" from Sep 30, 2020, leads to the following
Smatch static checker warning:

	drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:1151 mt7921_mcu_get_eeprom()
	error: potentially dereferencing uninitialized 'skb'.

drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
    1136 int mt7921_mcu_get_eeprom(struct mt7921_dev *dev, u32 offset)
    1137 {
    1138         struct mt7921_mcu_eeprom_info req = {
    1139                 .addr = cpu_to_le32(round_down(offset, 16)),
    1140         };
    1141         struct mt7921_mcu_eeprom_info *res;
    1142         struct sk_buff *skb;
    1143         int ret;
    1144         u8 *buf;
    1145 
    1146         ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_ACCESS, &req,
    1147                                         sizeof(req), true, &skb);

If mt76_mcu_send_and_get_msg() calls the dev->mcu_ops->mcu_send_msg()
then "skb" is not initialized.

    1148         if (ret)
    1149                 return ret;
    1150 
--> 1151         res = (struct mt7921_mcu_eeprom_info *)skb->data;
    1152         buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
    1153         memcpy(buf, res->data, 16);
    1154         dev_kfree_skb(skb);
    1155 
    1156         return 0;
    1157 }

regards,
dan carpenter

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

             reply	other threads:[~2021-10-08 13:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08 13:00 Dan Carpenter [this message]
2021-10-08 13:00 ` [bug report] mt76: implement functions to get the response skb for MCU calls Dan Carpenter
2021-10-08 14:03 ` Johannes Berg
2021-10-08 14:03   ` Johannes Berg
2021-10-08 14:27   ` Dan Carpenter
2021-10-08 14:27     ` Dan Carpenter
2021-10-08 14:35     ` Dan Carpenter
2021-10-08 14:35       ` Dan Carpenter
2022-10-13 13:04     ` Dan Carpenter
2022-10-13 16:25       ` Lorenzo Bianconi
2022-10-14  7:30         ` Dan Carpenter
2022-10-14  8:11           ` Lorenzo Bianconi

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=20211008130007.GA23161@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    /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.