Linux RTC
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: a.zummo@towertech.it
Cc: linux-rtc@vger.kernel.org
Subject: [bug report] [PATCH] RTC subsystem: class
Date: Thu, 15 Oct 2020 12:58:51 +0300	[thread overview]
Message-ID: <20201015095851.GA3042688@mwanda> (raw)

Hello Alessandro Zummo,

The patch 0c86edc0d497: "[PATCH] RTC subsystem: class" from Mar 27,
2006, leads to the following static checker warning:

	drivers/rtc/rtc-r9701.c:109 r9701_set_datetime()
	error: undefined (user controlled) shift '1 << dt->tm_wday'

drivers/rtc/rtc-r9701.c
    95  static int r9701_set_datetime(struct device *dev, struct rtc_time *dt)
    96  {
    97          int ret, year;
    98  
    99          year = dt->tm_year + 1900;
   100          if (year >= 2100 || year < 2000)
   101                  return -EINVAL;
   102  
   103          ret = write_reg(dev, RHRCNT, bin2bcd(dt->tm_hour));
   104          ret = ret ? ret : write_reg(dev, RMINCNT, bin2bcd(dt->tm_min));
   105          ret = ret ? ret : write_reg(dev, RSECCNT, bin2bcd(dt->tm_sec));
   106          ret = ret ? ret : write_reg(dev, RDAYCNT, bin2bcd(dt->tm_mday));
   107          ret = ret ? ret : write_reg(dev, RMONCNT, bin2bcd(dt->tm_mon + 1));
   108          ret = ret ? ret : write_reg(dev, RYRCNT, bin2bcd(dt->tm_year - 100));
   109          ret = ret ? ret : write_reg(dev, RWKCNT, 1 << dt->tm_wday);

I would have expected that rtc_valid_tm() would check that dt->tm_wday
as valid but it doesn't.  As far as I can see dt->tm_wday can be set to
any int value in the rtc_dev_ioctl(). 

   110  
   111          return ret;
   112  }

regards,
dan carpenter

             reply	other threads:[~2020-10-15  9:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15  9:58 Dan Carpenter [this message]
2020-10-15 17:38 ` [bug report] [PATCH] RTC subsystem: class Alexandre Belloni

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=20201015095851.GA3042688@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=a.zummo@towertech.it \
    --cc=linux-rtc@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