Skip to contentSkip to conversation

question about mtdchar.c

PATCH Axel Ludszuweit 2 participants 2 messages Dec 9, 2003 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hello everybody,

I have a question, concerning the MEMGETINFO part of the mtd_ioctl function, contained in .../mtd/drivers/mtd/mtdchar.c

I think, the right code is

               .
               .
	case MEMGETINFO:
		if (copy_to_user((struct mtd_info_user *)arg, mtd,
                                        ^^^^^^^^^^^^^ 
				 sizeof(struct mtd_info_user)))
			return -EFAULT;
		break;
               .
               .

instead

               .
               .
	case MEMGETINFO:
		if (copy_to_user((struct mtd_info *)arg, mtd,
                                        ^^^^^^^^
				 sizeof(struct mtd_info_user)))
			return -EFAULT;
		break;
               .
               .

I have attached the patch file.
Is this correct or have I not understand the code?

----------------------------------------------------------------------------

drivers/mtd/mtdchar.c 2003-12-09 10:57:01.000000000 +0100 renamed from drivers/mtd/mtdchar.c.ORIG 2003-12-09 10:55:14.000000000 +0100 +1 -1
@@ -283,7 +283,7 @@
       }
 
       case MEMGETINFO:
-               if (copy_to_user((struct mtd_info *)arg, mtd,
+               if (copy_to_user((struct mtd_info_user *)arg, mtd,
                                sizeof(struct mtd_info_user)))
                       return -EFAULT;
               break;

----------------------------------------------------------------------------

--------------------------------------------

Axel Ludszuweit

Keymile GmbH
Wohlenbergstr. 3, D-30179 Hannover

Tel.: +49 511 / 978197-630
Fax : +49 511 / 978197-670
http://www.keymile.com
mailto:[email protected]

Quoted 1 line
Quoted 1 line

Be the FIRST on the LAST MILE <<

#1 lore raw

drivers/mtd/mtdchar.c 2003-12-09 10:57:01.000000000 +0100 line 288

Quoted 5 lines · Axel Ludszuweit

case MEMGETINFO:

drivers/mtd/mtdchar.c 2003-12-09 10:57:01.000000000 +0100 renamed from drivers/mtd/mtdchar.c.ORIG 2003-12-09 10:55:14.000000000 +0100 +1 -1
-               if (copy_to_user((struct mtd_info *)arg, mtd,
+               if (copy_to_user((struct mtd_info_user *)arg, mtd,
                                 sizeof(struct mtd_info_user)))
                        return -EFAULT;

You're right -- thanks. But note that it's cosmetic; the type of the pointer is irrelevant and the length is correct.

Signature · 1 line
dwmw2