All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Nyberg <alexn@telia.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [Kernel-janitors] Sparse checks #9
Date: Wed, 16 Jun 2004 00:15:27 +0000	[thread overview]
Message-ID: <1087344927.676.147.camel@boxen> (raw)
In-Reply-To: <1087343099.676.115.camel@boxen>

[-- Attachment #1: Type: text/plain, Size: 7241 bytes --]

Sorry, stupid miss at:
struct lcd_display __user *ubuf = (struct lcd_display __user) arg;

Could I also have some feedback before I go on with this, right
way of sending in diffs etc.?

Resending drivers/char/lcd.c diff:

===== drivers/char/lcd.c 1.2 vs edited =====
--- 1.2/drivers/char/lcd.c      2003-09-01 01:14:08 +02:00
+++ edited/drivers/char/lcd.c   2004-06-16 00:27:01 +02:00
@@ -63,7 +63,8 @@
        struct lcd_display button_display;
        unsigned long address, a;
        int index;
-
+       struct lcd_display __user *ubuf = (struct lcd_display __user *) arg;
+
        switch (cmd) {
        case LCD_On:
                udelay(150);
@@ -135,8 +136,8 @@
                 BusyCheck();
                display.cursor_address = ( LCDReadInst );
                display.cursor_address = ( display.cursor_address & 0x07F );
-               if(copy_to_user((struct lcd_display*)arg, &display, sizeof(struct lcd_display)))
-                 return -EFAULT;
+               if(copy_to_user(ubuf, &display, sizeof(struct lcd_display)))
+                       return -EFAULT;

                break;
                }
@@ -145,7 +146,7 @@
        case LCD_Set_Cursor_Pos: {
                 struct lcd_display display;

-                if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
+                if(copy_from_user(&display, ubuf, sizeof(struct lcd_display)))
                  return -EFAULT;

                a = (display.cursor_address | kLCD_Addr );
@@ -164,8 +165,8 @@
                 BusyCheck();
                display.character = LCDReadData;

-               if(copy_to_user((struct lcd_display*)arg, &display, sizeof(struct lcd_display)))
-                 return -EFAULT;
+               if(copy_to_user(ubuf, &display, sizeof(struct lcd_display)))
+                       return -EFAULT;
                 udelay(150);
                 BusyCheck();
                 LCDWriteInst(0x10);
@@ -176,8 +177,8 @@
        case LCD_Set_Cursor:{
                 struct lcd_display display;

-                if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
-                 return -EFAULT;
+                if(copy_from_user(&display, ubuf, sizeof(struct lcd_display)))
+                       return -EFAULT;

                 udelay(150);
                BusyCheck();
@@ -212,8 +213,8 @@
                struct lcd_display display;


-                if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
-                 return -EFAULT;
+                if(copy_from_user(&display, ubuf, sizeof(struct lcd_display)))
+                       return -EFAULT;

                udelay(150);
                 BusyCheck();
@@ -273,9 +274,8 @@

                display.line2[ 0x27 ] = '\0';

-               if(copy_to_user((struct lcd_display*)arg, &display,
-                               sizeof(struct lcd_display)))
-                 return -EFAULT;
+               if(copy_to_user(ubuf, &display, sizeof(struct lcd_display)))
+                       return -EFAULT;
                break;
        }

@@ -285,9 +285,8 @@
                struct lcd_display led_display;


-               if(copy_from_user(&led_display, (struct lcd_display*)arg,
-                                 sizeof(struct lcd_display)))
-                 return -EFAULT;
+               if(copy_from_user(&led_display, ubuf, sizeof(struct lcd_display)))
+                       return -EFAULT;

                led_state = led_display.leds;
                LEDSet(led_state);
@@ -304,9 +303,8 @@
                 struct lcd_display led_display;


-                if(copy_from_user(&led_display, (struct lcd_display*)arg,
-                                 sizeof(struct lcd_display)))
-                 return -EFAULT;
+                if(copy_from_user(&led_display, ubuf, sizeof(struct lcd_display)))
+                       return -EFAULT;

                for (i=0;i<(int)led_display.leds;i++)
                        {
@@ -326,9 +324,8 @@
                 struct lcd_display led_display;


-                if(copy_from_user(&led_display, (struct lcd_display*)arg,
-                                 sizeof(struct lcd_display)))
-                 return -EFAULT;
+                if(copy_from_user(&led_display, ubuf, sizeof(struct lcd_display)))
+                       return -EFAULT;

                 for (i=0;i<(int)led_display.leds;i++)
                         {
@@ -343,15 +340,15 @@

        case BUTTON_Read: {
                button_display.buttons = GPIRead;
-                if(copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display)))
-                 return -EFAULT;
+                if(copy_to_user(ubuf, &button_display, sizeof(struct lcd_display)))
+                       return -EFAULT;
                break;
        }

         case LINK_Check: {
                 button_display.buttons = *((volatile unsigned long *) (0xB0100060) );
-                if(copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display)))
-                 return -EFAULT;
+                if(copy_to_user(ubuf, &button_display, sizeof(struct lcd_display)))
+                       return -EFAULT;
                 break;
         }

@@ -362,8 +359,8 @@
                 * in "buttons" of the structure.  We will set this to non-zero if the
                 * link is in fact up for the requested interface.  --DaveM
                 */
-               if(copy_from_user(&button_display, (struct lcd_display *)arg, sizeof(button_display)))
-                 return -EFAULT;
+               if(copy_from_user(&button_display, ubuf, sizeof(button_display)))
+                       return -EFAULT;
                iface_num = button_display.buttons;
 #if defined(CONFIG_TULIP) && 0
                if (iface_num >= 0 &&
@@ -375,8 +372,8 @@
 #endif
                        button_display.buttons = 0;

-                if(__copy_to_user((struct lcd_display*)arg, &button_display, sizeof(struct lcd_display)))
-                 return -EFAULT;
+                if(__copy_to_user(ubuf, &button_display, sizeof(struct lcd_display)))
+                       return -EFAULT;
                 break;
        }

@@ -422,7 +419,7 @@

                 struct lcd_display display;

-                if(copy_from_user(&display, (struct lcd_display*)arg, sizeof(struct lcd_display)))
+                if(copy_from_user(&display, ubuf, sizeof(struct lcd_display)))
                  return -EFAULT;
                rom = (unsigned char *) kmalloc((128),GFP_ATOMIC);
                 if ( rom == NULL ) {
@@ -471,7 +468,7 @@
                 volatile unsigned long read_addr;
                 int i;

-               user_bytes = &(((struct lcd_display *)arg)->RomImage[0]);
+               user_bytes = &ubuf->RomImage[0];

                if(!access_ok(VERIFY_WRITE, user_bytes, FLASH_SIZE))
                          return -EFAULT;
@@ -526,7 +523,7 @@

 static int lcd_waiters = 0;

-static long lcd_read(struct inode *inode, struct file *file, char *buf, unsigned long count)
+static long lcd_read(struct inode *inode, struct file *file, char __user *buf, unsigned long count)
 {
        long buttons_now;




[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

  reply	other threads:[~2004-06-16  0:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-15 23:45 [Kernel-janitors] Sparse checks #9 Alexander Nyberg
2004-06-16  0:15 ` Alexander Nyberg [this message]
2004-06-16  4:02 ` Randy.Dunlap
2004-06-16 14:58 ` "Alexey Dobriyan" 

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=1087344927.676.147.camel@boxen \
    --to=alexn@telia.com \
    --cc=kernel-janitors@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 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.