Skip to contentSkip to conversation

ati_pcigart: fix format type warning

PATCH In review Borislav Petkov 2 participants 3 messages Jan 17, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ati_pcigart: fix format type warning

Fix the following warning:

drivers/gpu/drm/ati_pcigart.c: In function ‘drm_ati_pcigart_init’:
drivers/gpu/drm/ati_pcigart.c:115: warning: format ‘%Lx’ expects type ‘long long unsigned int’, but argument 3 has type ‘dma_addr_t’

---
 drivers/gpu/drm/ati_pcigart.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpu/drm/ati_pcigart.c +1 -1
index a1fce68..a631e19 100644
@@ -113,7 +113,7 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
 
 		if (pci_set_dma_mask(dev->pdev, gart_info->table_mask)) {
 			DRM_ERROR("fail to set dma mask to 0x%Lx\n",
-				  gart_info->table_mask);
+				  (u64)gart_info->table_mask);
 			ret = 1;
 			goto done;
 		}
Signature · 18 lines
1.6.6


-- 
Regards/Gruss,
    Boris.

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
#1 lore raw

I'm also getting

CC drivers/gpu/drm/radeon/radeon_state.o
In file included from /home/boris/kernel/linux-2.6/arch/x86/include/asm/uaccess.h:571,

                 from include/drm/drmP.h:63,
                 from drivers/gpu/drm/radeon/radeon_state.c:30:

In function ‘copy_from_user’,
inlined from ‘radeon_cp_clear’ at drivers/gpu/drm/radeon/radeon_state.c:2145:
/home/boris/kernel/linux-2.6/arch/x86/include/asm/uaccess_32.h:212: warning: call to ‘copy_from_user_overflow’ declared with attribute warning: copy_from_user() buffer size is not provably correct
LD drivers/gpu/drm/radeon/radeon.o

which is caused by the compile-time check in copy_from_user introduced in 4a312769:

        if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
                               sarea_priv->nbox * sizeof(depth_boxes[0])))

due to the sarea_priv->nbox being unknown at compile time, even though the code clamps its value earlier in case it might cause an overflow:

        if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
                sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;

Circumventing the check shuts up the warning but I'm not sure whether this is what we want to do in cases like this one:

--

drivers/gpu/drm/radeon/radeon_state.c +1 -1
index 067167c..9b42598 100644
@@ -2139,7 +2139,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
 	if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
 		sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
 
-	if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
+	if (_copy_from_user(&depth_boxes, clear->depth_boxes,
 			       sarea_priv->nbox * sizeof(depth_boxes[0])))
 		return -EFAULT;
 
Signature · 14 lines
Regards/Gruss,
    Boris.

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
#2 lore raw
Quoted 14 lines · On Sun, 17 Jan 2010 19:41:20 +0100 Borislav Petkov <[email protected]>…

drivers/gpu/drm/radeon/radeon_state.c:2145: /home/boris/kernel/linux-2.6/arch/x86/include/asm/uaccess_32.h:212:
warning: call to ‘copy_from_user_overflow’ declared with attribute
warning: copy_from_user() buffer size is not provably correct LD drivers/gpu/drm/radeon/radeon.o

which is caused by the compile-time check in copy_from_user introduced in 4a312769:

        if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
                               sarea_priv->nbox *

sizeof(depth_boxes[0])))

Quoted 6 lines

due to the sarea_priv->nbox being unknown at compile time, even though the code clamps its value earlier in case it might cause an overflow:

        if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
                sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;

gcc is not smart enough to prove that the clamp survives the multiplication without wrapping it seems.

Signature · 15 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel