X86 platform drivers
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: markpearson@lenovo.com
Cc: platform-driver-x86@vger.kernel.org
Subject: [bug report] platform/x86: think-lmi: Add WMI interface support on Lenovo platforms
Date: Wed, 9 Jun 2021 13:43:08 +0300	[thread overview]
Message-ID: <YMCbPNqiuso+k2rk@mwanda> (raw)

Hello Mark Pearson,

The patch a7314b3b1d8a: "platform/x86: think-lmi: Add WMI interface
support on Lenovo platforms" from May 30, 2021, leads to the
following static checker warning:

	drivers/platform/x86/think-lmi.c:453 kbdlang_store()
	error: iterator underflow 'setting->kbdlang' (-1),1-3

drivers/platform/x86/think-lmi.c
   438  static ssize_t kbdlang_store(struct kobject *kobj,
   439                                    struct kobj_attribute *attr,
   440                                    const char *buf, size_t count)
   441  {
   442          struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
   443          int length;
   444  
   445          length = strlen(buf);

"count" can never be zero, but strlen(buf) can be zero.

   446          if (buf[length-1] == '\n')
                        ^^^^^^^^
So this code can read before the start of the buffer, potentially
leading to an Oops.

   447                  length--;
   448  
   449          if (!length || (length >= TLMI_LANG_MAXLEN))
   450                  return -EINVAL;
   451  
   452          memcpy(setting->kbdlang, buf, length);
   453          setting->kbdlang[length] = '\0';
   454          return count;
   455  }

regards,
dan carpenter

             reply	other threads:[~2021-06-09 10:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 10:43 Dan Carpenter [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-06-09 10:18 [bug report] platform/x86: think-lmi: Add WMI interface support on Lenovo platforms Dan Carpenter

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=YMCbPNqiuso+k2rk@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=markpearson@lenovo.com \
    --cc=platform-driver-x86@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