All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-pm@vger.kernel.org, "Zhang, Rui" <rui.zhang@intel.com>
Subject: Re: Thermal: int340x_thermal: expose acpi thermal relationship tables
Date: Tue, 4 Nov 2014 15:23:11 -0800	[thread overview]
Message-ID: <20141104152311.39e02f7e@icelake> (raw)
In-Reply-To: <20141013174111.GA8390@mwanda>

On Mon, 13 Oct 2014 20:41:11 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> Hello Jacob Pan,
> 
> The patch 52b1c69d7e3c: "Thermal: int340x_thermal: expose acpi
> thermal relationship tables" from Sep 3, 2014, leads to the following
> static checker warning:
> 
> 	drivers/thermal/int340x_thermal/acpi_thermal_rel.c:327
> acpi_thermal_rel_ioctl() warn: passing casted pointer '&count' to
> 'acpi_parse_trt()' 64 vs 32.
> 
> drivers/thermal/int340x_thermal/acpi_thermal_rel.c
>    315  static long acpi_thermal_rel_ioctl(struct file *f, unsigned
> int cmd, 316                                     unsigned long __arg)
>    317  {
>    318          int ret = 0;
>    319          unsigned long length = 0;
>    320          unsigned long count = 0;
>    321          char __user *arg = (void __user *)__arg;
>    322          struct trt *trts;
>    323          struct art *arts;
>    324  
>    325          switch (cmd) {
>    326          case ACPI_THERMAL_GET_TRT_COUNT:
>    327                  ret = acpi_parse_trt(acpi_thermal_rel_handle,
> (int *)&count, ^^^^^^^^^^^^
> The reason for the static checker warning is that this will not work
> on big endian 64 bit systems.  It's most likely not a concern but it's
> still pretty ugly.
> 
> You could just make "count" an int and remove the casting.  The copy
> to user will still work if it's an int because the user pointer has
> been casted to unsigned long __user pointer.
you are right, I will make the change. Thanks for pointing this out and
sorry for the late response, I was traveling.

> 
>    328                                  &trts, false);
>    329                  kfree(trts);
>    330                  if (!ret)
>    331                          return put_user(count, (unsigned long
> __user *)__arg); 332                  return ret;
>    333          case ACPI_THERMAL_GET_TRT_LEN:
> 
> regards,
> dan carpenter

[Jacob Pan]

      reply	other threads:[~2014-11-04 23:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-13 17:41 Thermal: int340x_thermal: expose acpi thermal relationship tables Dan Carpenter
2014-11-04 23:23 ` Jacob Pan [this message]

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=20141104152311.39e02f7e@icelake \
    --to=jacob.jun.pan@linux.intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.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 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.