Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] dw2102: Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Thomas Meyer and committed by
Mauro Carvalho Chehab
68dd9dd4 53090aad

+6 -9
+6 -9
drivers/media/dvb/dvb-usb/dw2102.c
··· 1859 1859 static int dw2102_probe(struct usb_interface *intf, 1860 1860 const struct usb_device_id *id) 1861 1861 { 1862 - p1100 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1862 + p1100 = kmemdup(&s6x0_properties, 1863 + sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1863 1864 if (!p1100) 1864 1865 return -ENOMEM; 1865 1866 /* copy default structure */ 1866 - memcpy(p1100, &s6x0_properties, 1867 - sizeof(struct dvb_usb_device_properties)); 1868 1867 /* fill only different fields */ 1869 1868 p1100->firmware = "dvb-usb-p1100.fw"; 1870 1869 p1100->devices[0] = d1100; ··· 1871 1872 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); 1872 1873 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach; 1873 1874 1874 - s660 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1875 + s660 = kmemdup(&s6x0_properties, 1876 + sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1875 1877 if (!s660) { 1876 1878 kfree(p1100); 1877 1879 return -ENOMEM; 1878 1880 } 1879 - memcpy(s660, &s6x0_properties, 1880 - sizeof(struct dvb_usb_device_properties)); 1881 1881 s660->firmware = "dvb-usb-s660.fw"; 1882 1882 s660->num_device_descs = 3; 1883 1883 s660->devices[0] = d660; ··· 1884 1886 s660->devices[2] = d480_2; 1885 1887 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach; 1886 1888 1887 - p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1889 + p7500 = kmemdup(&s6x0_properties, 1890 + sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1888 1891 if (!p7500) { 1889 1892 kfree(p1100); 1890 1893 kfree(s660); 1891 1894 return -ENOMEM; 1892 1895 } 1893 - memcpy(p7500, &s6x0_properties, 1894 - sizeof(struct dvb_usb_device_properties)); 1895 1896 p7500->firmware = "dvb-usb-p7500.fw"; 1896 1897 p7500->devices[0] = d7500; 1897 1898 p7500->rc.legacy.rc_map_table = rc_map_tbs_table;