@@ -328,14 +328,13 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
328328 return - EINVAL ;
329329 }
330330
331- list = kmalloc (sizeof (* list ), GFP_KERNEL );
331+ list = kzalloc (sizeof (* list ), GFP_KERNEL );
332332 if (!list ) {
333333 if (map -> type == _DRM_REGISTERS )
334334 iounmap (map -> handle );
335335 kfree (map );
336336 return - EINVAL ;
337337 }
338- memset (list , 0 , sizeof (* list ));
339338 list -> map = map ;
340339
341340 mutex_lock (& dev -> struct_mutex );
@@ -678,13 +677,12 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
678677 return - EINVAL ;
679678 }
680679
681- entry -> buflist = kmalloc (count * sizeof (* entry -> buflist ), GFP_KERNEL );
680+ entry -> buflist = kzalloc (count * sizeof (* entry -> buflist ), GFP_KERNEL );
682681 if (!entry -> buflist ) {
683682 mutex_unlock (& dev -> struct_mutex );
684683 atomic_dec (& dev -> buf_alloc );
685684 return - ENOMEM ;
686685 }
687- memset (entry -> buflist , 0 , count * sizeof (* entry -> buflist ));
688686
689687 entry -> buf_size = size ;
690688 entry -> page_order = page_order ;
@@ -708,7 +706,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
708706 buf -> file_priv = NULL ;
709707
710708 buf -> dev_priv_size = dev -> driver -> dev_priv_size ;
711- buf -> dev_private = kmalloc (buf -> dev_priv_size , GFP_KERNEL );
709+ buf -> dev_private = kzalloc (buf -> dev_priv_size , GFP_KERNEL );
712710 if (!buf -> dev_private ) {
713711 /* Set count correctly so we free the proper amount. */
714712 entry -> buf_count = count ;
@@ -717,7 +715,6 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
717715 atomic_dec (& dev -> buf_alloc );
718716 return - ENOMEM ;
719717 }
720- memset (buf -> dev_private , 0 , buf -> dev_priv_size );
721718
722719 DRM_DEBUG ("buffer %d @ %p\n" , entry -> buf_count , buf -> address );
723720
@@ -832,22 +829,20 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
832829 return - EINVAL ;
833830 }
834831
835- entry -> buflist = kmalloc (count * sizeof (* entry -> buflist ), GFP_KERNEL );
832+ entry -> buflist = kzalloc (count * sizeof (* entry -> buflist ), GFP_KERNEL );
836833 if (!entry -> buflist ) {
837834 mutex_unlock (& dev -> struct_mutex );
838835 atomic_dec (& dev -> buf_alloc );
839836 return - ENOMEM ;
840837 }
841- memset (entry -> buflist , 0 , count * sizeof (* entry -> buflist ));
842838
843- entry -> seglist = kmalloc (count * sizeof (* entry -> seglist ), GFP_KERNEL );
839+ entry -> seglist = kzalloc (count * sizeof (* entry -> seglist ), GFP_KERNEL );
844840 if (!entry -> seglist ) {
845841 kfree (entry -> buflist );
846842 mutex_unlock (& dev -> struct_mutex );
847843 atomic_dec (& dev -> buf_alloc );
848844 return - ENOMEM ;
849845 }
850- memset (entry -> seglist , 0 , count * sizeof (* entry -> seglist ));
851846
852847 /* Keep the original pagelist until we know all the allocations
853848 * have succeeded
@@ -911,8 +906,8 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
911906 buf -> file_priv = NULL ;
912907
913908 buf -> dev_priv_size = dev -> driver -> dev_priv_size ;
914- buf -> dev_private = kmalloc (buf -> dev_priv_size ,
915- GFP_KERNEL );
909+ buf -> dev_private = kzalloc (buf -> dev_priv_size ,
910+ GFP_KERNEL );
916911 if (!buf -> dev_private ) {
917912 /* Set count correctly so we free the proper amount. */
918913 entry -> buf_count = count ;
@@ -923,7 +918,6 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
923918 atomic_dec (& dev -> buf_alloc );
924919 return - ENOMEM ;
925920 }
926- memset (buf -> dev_private , 0 , buf -> dev_priv_size );
927921
928922 DRM_DEBUG ("buffer %d @ %p\n" ,
929923 entry -> buf_count , buf -> address );
@@ -1048,14 +1042,13 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
10481042 return - EINVAL ;
10491043 }
10501044
1051- entry -> buflist = kmalloc (count * sizeof (* entry -> buflist ),
1045+ entry -> buflist = kzalloc (count * sizeof (* entry -> buflist ),
10521046 GFP_KERNEL );
10531047 if (!entry -> buflist ) {
10541048 mutex_unlock (& dev -> struct_mutex );
10551049 atomic_dec (& dev -> buf_alloc );
10561050 return - ENOMEM ;
10571051 }
1058- memset (entry -> buflist , 0 , count * sizeof (* entry -> buflist ));
10591052
10601053 entry -> buf_size = size ;
10611054 entry -> page_order = page_order ;
@@ -1080,7 +1073,7 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
10801073 buf -> file_priv = NULL ;
10811074
10821075 buf -> dev_priv_size = dev -> driver -> dev_priv_size ;
1083- buf -> dev_private = kmalloc (buf -> dev_priv_size , GFP_KERNEL );
1076+ buf -> dev_private = kzalloc (buf -> dev_priv_size , GFP_KERNEL );
10841077 if (!buf -> dev_private ) {
10851078 /* Set count correctly so we free the proper amount. */
10861079 entry -> buf_count = count ;
@@ -1090,8 +1083,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
10901083 return - ENOMEM ;
10911084 }
10921085
1093- memset (buf -> dev_private , 0 , buf -> dev_priv_size );
1094-
10951086 DRM_DEBUG ("buffer %d @ %p\n" , entry -> buf_count , buf -> address );
10961087
10971088 offset += alignment ;
@@ -1209,14 +1200,13 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
12091200 return - EINVAL ;
12101201 }
12111202
1212- entry -> buflist = kmalloc (count * sizeof (* entry -> buflist ),
1203+ entry -> buflist = kzalloc (count * sizeof (* entry -> buflist ),
12131204 GFP_KERNEL );
12141205 if (!entry -> buflist ) {
12151206 mutex_unlock (& dev -> struct_mutex );
12161207 atomic_dec (& dev -> buf_alloc );
12171208 return - ENOMEM ;
12181209 }
1219- memset (entry -> buflist , 0 , count * sizeof (* entry -> buflist ));
12201210
12211211 entry -> buf_size = size ;
12221212 entry -> page_order = page_order ;
@@ -1240,7 +1230,7 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
12401230 buf -> file_priv = NULL ;
12411231
12421232 buf -> dev_priv_size = dev -> driver -> dev_priv_size ;
1243- buf -> dev_private = kmalloc (buf -> dev_priv_size , GFP_KERNEL );
1233+ buf -> dev_private = kzalloc (buf -> dev_priv_size , GFP_KERNEL );
12441234 if (!buf -> dev_private ) {
12451235 /* Set count correctly so we free the proper amount. */
12461236 entry -> buf_count = count ;
@@ -1249,7 +1239,6 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
12491239 atomic_dec (& dev -> buf_alloc );
12501240 return - ENOMEM ;
12511241 }
1252- memset (buf -> dev_private , 0 , buf -> dev_priv_size );
12531242
12541243 DRM_DEBUG ("buffer %d @ %p\n" , entry -> buf_count , buf -> address );
12551244
0 commit comments