check the allocation of the name list
use a macro get_handle git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23490 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#define copy_from_user memcpy
|
#define copy_from_user memcpy
|
||||||
#define copy_to_user memcpy
|
#define copy_to_user memcpy
|
||||||
#define CardServices gPcmciaCs->_CardServices
|
#define CardServices gPcmciaCs->_CardServices
|
||||||
|
#define get_handle gPcmciaDs->get_handle
|
||||||
|
|
||||||
const char sockname[] = "bus/pcmcia/sock/%ld";
|
const char sockname[] = "bus/pcmcia/sock/%ld";
|
||||||
static char ** devices;
|
static char ** devices;
|
||||||
@@ -50,7 +51,7 @@ ds_open(const char *name, uint32 flags, void **_cookie)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gPcmciaDs->get_handle(socket, (client_handle_t *)_cookie) != B_OK) {
|
if (get_handle(socket, (client_handle_t *)_cookie) != B_OK) {
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +366,7 @@ init_driver()
|
|||||||
}
|
}
|
||||||
|
|
||||||
devices_count = 0;
|
devices_count = 0;
|
||||||
while (gPcmciaDs->get_handle(devices_count, &handle)==B_OK) {
|
while (get_handle(devices_count, &handle)==B_OK) {
|
||||||
devices_count++;
|
devices_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,6 +377,11 @@ init_driver()
|
|||||||
}
|
}
|
||||||
|
|
||||||
devices = malloc(sizeof(char *) * (devices_count+1));
|
devices = malloc(sizeof(char *) * (devices_count+1));
|
||||||
|
if (!devices) {
|
||||||
|
put_module(CS_CLIENT_MODULE_NAME);
|
||||||
|
put_module(DS_MODULE_NAME);
|
||||||
|
return ENOMEM;
|
||||||
|
}
|
||||||
for (i=0; i<devices_count; i++) {
|
for (i=0; i<devices_count; i++) {
|
||||||
devices[i] = strdup(sockname);
|
devices[i] = strdup(sockname);
|
||||||
sprintf(devices[i], sockname, i);
|
sprintf(devices[i], sockname, i);
|
||||||
@@ -394,6 +400,7 @@ uninit_driver()
|
|||||||
free (devices[i]);
|
free (devices[i]);
|
||||||
}
|
}
|
||||||
free(devices);
|
free(devices);
|
||||||
|
devices = NULL;
|
||||||
|
|
||||||
put_module(DS_MODULE_NAME);
|
put_module(DS_MODULE_NAME);
|
||||||
put_module(CS_CLIENT_MODULE_NAME);
|
put_module(CS_CLIENT_MODULE_NAME);
|
||||||
|
|||||||
Reference in New Issue
Block a user