]> git.hungrycats.org Git - linux/commitdiff
wifi: mt76: mt7615: check devm_kasprintf() returned value
authorMa Ke <make24@iscas.ac.cn>
Thu, 5 Sep 2024 01:47:53 +0000 (09:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:33:37 +0000 (16:33 +0200)
commit 5acdc432f832d810e0d638164c393b877291d9b4 upstream.

devm_kasprintf() can return a NULL pointer on failure but this returned
value is not checked. Fix this lack and check the returned value.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: 0bb4e9187ea4 ("mt76: mt7615: fix hwmon temp sensor mem use-after-free")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://patch.msgid.link/20240905014753.353271-1-make24@iscas.ac.cn
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/mediatek/mt76/mt7615/init.c

index f7722f67db576f9a1d7191d11c52905a155c25cc..0b9ebdcda221e44f2fd3c9c450a9cafb37ad1356 100644 (file)
@@ -56,6 +56,9 @@ int mt7615_thermal_init(struct mt7615_dev *dev)
 
        name = devm_kasprintf(&wiphy->dev, GFP_KERNEL, "mt7615_%s",
                              wiphy_name(wiphy));
+       if (!name)
+               return -ENOMEM;
+
        hwmon = devm_hwmon_device_register_with_groups(&wiphy->dev, name, dev,
                                                       mt7615_hwmon_groups);
        return PTR_ERR_OR_ZERO(hwmon);