Linux-Hwmon Archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: savicaleksa83@gmail.com
Cc: linux-hwmon@vger.kernel.org
Subject: [bug report] hwmon: (nzxt-kraken3) Decouple device names from kinds
Date: Fri, 10 May 2024 17:00:05 +0300	[thread overview]
Message-ID: <b1738c50-db42-40f0-a899-9c027c131ffb@moroto.mountain> (raw)

Hello Aleksa Savic,

Commit 346e147a91f2 ("hwmon: (nzxt-kraken3) Decouple device names
from kinds") from Apr 28, 2024 (linux-next), leads to the following
Smatch static checker warning:

	drivers/hwmon/nzxt-kraken3.c:957 kraken3_probe()
	error: uninitialized symbol 'device_name'.

drivers/hwmon/nzxt-kraken3.c
    873 static int kraken3_probe(struct hid_device *hdev, const struct hid_device_id *id)
    874 {
    875         struct kraken3_data *priv;
    876         const char *device_name;
    877         int ret;
    878 
    879         priv = devm_kzalloc(&hdev->dev, sizeof(*priv), GFP_KERNEL);
    880         if (!priv)
    881                 return -ENOMEM;
    882 
    883         priv->hdev = hdev;
    884         hid_set_drvdata(hdev, priv);
    885 
    886         /*
    887          * Initialize ->updated to STATUS_VALIDITY seconds in the past, making
    888          * the initial empty data invalid for kraken3_read without the need for
    889          * a special case there.
    890          */
    891         priv->updated = jiffies - msecs_to_jiffies(STATUS_VALIDITY);
    892 
    893         ret = hid_parse(hdev);
    894         if (ret) {
    895                 hid_err(hdev, "hid parse failed with %d\n", ret);
    896                 return ret;
    897         }
    898 
    899         /* Enable hidraw so existing user-space tools can continue to work */
    900         ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
    901         if (ret) {
    902                 hid_err(hdev, "hid hw start failed with %d\n", ret);
    903                 return ret;
    904         }
    905 
    906         ret = hid_hw_open(hdev);
    907         if (ret) {
    908                 hid_err(hdev, "hid hw open failed with %d\n", ret);
    909                 goto fail_and_stop;
    910         }
    911 
    912         switch (hdev->product) {
    913         case USB_PRODUCT_ID_X53:
    914         case USB_PRODUCT_ID_X53_SECOND:
    915                 priv->kind = X53;
    916                 device_name = "x53";
    917                 break;
    918         case USB_PRODUCT_ID_Z53:
    919                 priv->kind = Z53;
    920                 device_name = "z53";
    921                 break;
    922         case USB_PRODUCT_ID_KRAKEN2023:
    923                 priv->kind = KRAKEN2023;
    924                 device_name = "kraken2023";
    925                 break;
    926         case USB_PRODUCT_ID_KRAKEN2023_ELITE:
    927                 priv->kind = KRAKEN2023;
    928                 device_name = "kraken2023elite";
    929                 break;
    930         default:
    931                 break;

device_name is uninitialized on this path.  Probably just error out
here?

    932         }
    933 
    934         priv->buffer = devm_kzalloc(&hdev->dev, MAX_REPORT_LENGTH, GFP_KERNEL);
    935         if (!priv->buffer) {
    936                 ret = -ENOMEM;
    937                 goto fail_and_close;
    938         }
    939 
    940         mutex_init(&priv->buffer_lock);
    941         mutex_init(&priv->z53_status_request_lock);
    942         init_completion(&priv->fw_version_processed);
    943         init_completion(&priv->status_report_processed);
    944         spin_lock_init(&priv->status_completion_lock);
    945 
    946         hid_device_io_start(hdev);
    947         ret = kraken3_init_device(hdev);
    948         if (ret < 0) {
    949                 hid_err(hdev, "device init failed with %d\n", ret);
    950                 goto fail_and_close;
    951         }
    952 
    953         ret = kraken3_get_fw_ver(hdev);
    954         if (ret < 0)
    955                 hid_warn(hdev, "fw version request failed with %d\n", ret);
    956 
--> 957         priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, device_name, priv,
                                                                              ^^^^^^^^^^^

    958                                                           &kraken3_chip_info, kraken3_groups);
    959         if (IS_ERR(priv->hwmon_dev)) {
    960                 ret = PTR_ERR(priv->hwmon_dev);
    961                 hid_err(hdev, "hwmon registration failed with %d\n", ret);
    962                 goto fail_and_close;
    963         }
    964 
    965         kraken3_debugfs_init(priv, device_name);
    966 
    967         return 0;
    968 
    969 fail_and_close:
    970         hid_hw_close(hdev);
    971 fail_and_stop:
    972         hid_hw_stop(hdev);
    973         return ret;
    974 }

regards,
dan carpenter

                 reply	other threads:[~2024-05-10 14:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=b1738c50-db42-40f0-a899-9c027c131ffb@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=savicaleksa83@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 read-only IMAP folder(s) and NNTP newsgroup(s).