From: Michael Buesch <mb@bu3sch.de>
To: Tony Lindgren <tony@atomide.com>
Cc: Felipe Balbi <balbi@ti.com>, linux-omap <linux-omap@vger.kernel.org>
Subject: [PATCH] cbus-retu-wdt: Fix bitfield access
Date: Wed, 02 Mar 2011 17:11:53 +0100 [thread overview]
Message-ID: <1299082313.13604.13.camel@marge> (raw)
An unsigned int pointer must not be casted to an unsigned
long pointer before use. Convert the bitfield to unsigned long
to fix this.
Also use clear_bit() in the release path.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
---
Index: linux-2.6.38-rc6/drivers/cbus/retu-wdt.c
===================================================================
--- linux-2.6.38-rc6.orig/drivers/cbus/retu-wdt.c 2011-03-02 16:46:24.574676092 +0100
+++ linux-2.6.38-rc6/drivers/cbus/retu-wdt.c 2011-03-02 16:48:17.469807413 +0100
@@ -56,7 +56,7 @@ static int counter_param = RETU_WDT_MAX_
struct retu_wdt_dev {
struct device *dev;
- int users;
+ unsigned long users;
struct miscdevice retu_wdt_miscdev;
struct delayed_work ping_work;
};
@@ -161,7 +161,7 @@ static DEVICE_ATTR(counter, S_IRUGO, ret
static int retu_wdt_open(struct inode *inode, struct file *file)
{
- if (test_and_set_bit(1, (unsigned long *)&(retu_wdt->users)))
+ if (test_and_set_bit(0, &retu_wdt->users))
return -EBUSY;
file->private_data = (void *)retu_wdt;
@@ -177,7 +177,7 @@ static int retu_wdt_release(struct inode
#ifndef CONFIG_WATCHDOG_NOWAYOUT
retu_wdt_ping_enable(retu_wdt);
#endif
- wdev->users = 0;
+ clear_bit(0, &retu_wdt->users);
return 0;
}
@@ -264,7 +264,6 @@ static int __init retu_wdt_probe(struct
return -ENOMEM;
wdev->dev = &pdev->dev;
- wdev->users = 0;
ret = device_create_file(&pdev->dev, &dev_attr_period);
if (ret) {
--
Greetings, Michael.
next reply other threads:[~2011-03-02 16:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-02 16:11 Michael Buesch [this message]
2011-03-03 9:43 ` [PATCH] cbus-retu-wdt: Fix bitfield access Felipe Balbi
2011-03-03 14:21 ` Michael Büsch
2011-03-03 14:27 ` Felipe Balbi
2011-03-03 14:36 ` Michael Büsch
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=1299082313.13604.13.camel@marge \
--to=mb@bu3sch.de \
--cc=balbi@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.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