Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
etherlabmaster
Commits
076b11d4
Commit
076b11d4
authored
19 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix: Discovered memory leak.
parent
c5a0dcc8
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
master/canopen.c
+8
-10
8 additions, 10 deletions
master/canopen.c
master/master.c
+9
-12
9 additions, 12 deletions
master/master.c
master/module.c
+1
-1
1 addition, 1 deletion
master/module.c
master/slave.c
+2
-0
2 additions, 0 deletions
master/slave.c
with
20 additions
and
23 deletions
master/canopen.c
+
8
−
10
View file @
076b11d4
...
...
@@ -415,7 +415,7 @@ int ec_slave_fetch_sdo_entries(ec_slave_t *slave, /**< EtherCAT-Slave */
EC_READ_U16
(
data
+
6
)
!=
sdo
->
index
||
// SDO index
EC_READ_U8
(
data
+
8
)
!=
i
)
{
// SDO subindex
EC_ERR
(
"Invalid entry description response at slave %i while"
" fetching SDO 0x%04X:%i!
\n
"
,
slave
->
ring_position
,
" fetching SDO
entry
0x%04X:%i!
\n
"
,
slave
->
ring_position
,
sdo
->
index
,
i
);
ec_print_data
(
data
,
rec_size
);
return
-
1
;
...
...
@@ -434,21 +434,19 @@ int ec_slave_fetch_sdo_entries(ec_slave_t *slave, /**< EtherCAT-Slave */
if
(
!
(
entry
=
(
ec_sdo_entry_t
*
)
kmalloc
(
sizeof
(
ec_sdo_entry_t
)
+
data_size
+
1
,
GFP_KERNEL
)))
{
EC_ERR
(
"Failed to allocate entry
memory
!
\n
"
);
EC_ERR
(
"Failed to allocate entry!
\n
"
);
return
-
1
;
}
entry
->
subindex
=
i
;
entry
->
data_type
=
EC_READ_U16
(
data
+
10
);
entry
->
bit_length
=
EC_READ_U16
(
data
+
12
);
if
(
!
data_size
)
{
entry
->
name
=
NULL
;
}
else
{
entry
->
name
=
(
uint8_t
*
)
entry
+
sizeof
(
ec_sdo_entry_t
);
memcpy
(
entry
->
name
,
data
+
16
,
data_size
);
entry
->
name
[
data_size
]
=
0
;
}
// memory for name string appended to entry
entry
->
name
=
(
uint8_t
*
)
entry
+
sizeof
(
ec_sdo_entry_t
);
memcpy
(
entry
->
name
,
data
+
16
,
data_size
);
entry
->
name
[
data_size
]
=
0
;
list_add_tail
(
&
entry
->
list
,
&
sdo
->
entries
);
}
...
...
This diff is collapsed.
Click to expand it.
master/master.c
+
9
−
12
View file @
076b11d4
...
...
@@ -86,9 +86,8 @@ void ec_master_reset(ec_master_t *master
// Alle Slaves entfernen
if
(
master
->
slaves
)
{
for
(
i
=
0
;
i
<
master
->
slave_count
;
i
++
)
{
for
(
i
=
0
;
i
<
master
->
slave_count
;
i
++
)
ec_slave_clear
(
master
->
slaves
+
i
);
}
kfree
(
master
->
slaves
);
master
->
slaves
=
NULL
;
}
...
...
@@ -108,7 +107,7 @@ void ec_master_reset(ec_master_t *master
}
// EOE-Liste leeren
list_for_each_entry_safe
(
eoe
,
next_eoe
,
&
master
->
domain
s
,
list
)
{
list_for_each_entry_safe
(
eoe
,
next_eoe
,
&
master
->
eoe_slave
s
,
list
)
{
list_del
(
&
eoe
->
list
);
ec_eoe_clear
(
eoe
);
kfree
(
eoe
);
...
...
@@ -411,10 +410,9 @@ int ec_master_bus_scan(ec_master_t *master /**< EtherCAT-Master */)
if
(
!
master
->
slave_count
)
return
0
;
if
(
!
(
master
->
slaves
=
(
ec_slave_t
*
)
kmalloc
(
master
->
slave_count
*
sizeof
(
ec_slave_t
),
GFP_KERNEL
)))
{
EC_ERR
(
"Could not allocate memory for slaves!
\n
"
);
if
(
!
(
master
->
slaves
=
(
ec_slave_t
*
)
kmalloc
(
master
->
slave_count
*
sizeof
(
ec_slave_t
),
GFP_KERNEL
)))
{
EC_ERR
(
"Failed to allocate slaves!
\n
"
);
return
-
1
;
}
...
...
@@ -426,9 +424,8 @@ int ec_master_bus_scan(ec_master_t *master /**< EtherCAT-Master */)
slave
->
station_address
=
i
+
1
;
}
// For every slave in the list
for
(
i
=
0
;
i
<
master
->
slave_count
;
i
++
)
{
// For every slave on the bus
for
(
i
=
0
;
i
<
master
->
slave_count
;
i
++
)
{
slave
=
master
->
slaves
+
i
;
// Write station address
...
...
@@ -461,8 +458,8 @@ int ec_master_bus_scan(ec_master_t *master /**< EtherCAT-Master */)
// Does the slave support EoE?
if
(
slave
->
sii_mailbox_protocols
&
EC_MBOX_EOE
)
{
if
(
!
(
eoe
=
kmalloc
(
sizeof
(
ec_eoe_t
),
GFP_KERNEL
)))
{
EC_ERR
(
"Failed to allocate
memory for
EoE-Object.
\n
"
);
if
(
!
(
eoe
=
(
ec_eoe_t
*
)
kmalloc
(
sizeof
(
ec_eoe_t
),
GFP_KERNEL
)))
{
EC_ERR
(
"Failed to allocate EoE-Object.
\n
"
);
return
-
1
;
}
...
...
This diff is collapsed.
Click to expand it.
master/module.c
+
1
−
1
View file @
076b11d4
...
...
@@ -176,7 +176,7 @@ ec_device_t *ecdev_register(unsigned int master_index,
if
(
!
(
master
->
device
=
(
ec_device_t
*
)
kmalloc
(
sizeof
(
ec_device_t
),
GFP_KERNEL
)))
{
EC_ERR
(
"Failed allocat
ing
device!
\n
"
);
EC_ERR
(
"Failed
to
allocat
e
device!
\n
"
);
return
NULL
;
}
...
...
This diff is collapsed.
Click to expand it.
master/slave.c
+
2
−
0
View file @
076b11d4
...
...
@@ -126,6 +126,7 @@ void ec_slave_clear(ec_slave_t *slave /**< EtherCAT-Slave */)
list_for_each_entry_safe
(
sdo
,
next_sdo
,
&
slave
->
sdo_dictionary
,
list
)
{
list_del
(
&
sdo
->
list
);
if
(
sdo
->
name
)
kfree
(
sdo
->
name
);
// Alle Entries freigeben
list_for_each_entry_safe
(
en
,
next_en
,
&
sdo
->
entries
,
list
)
{
list_del
(
&
en
->
list
);
...
...
@@ -541,6 +542,7 @@ int ec_slave_fetch_strings(ec_slave_t *slave, /**< EtherCAT-Slave */
return
-
1
;
}
string
->
size
=
size
;
// string memory appended to string structure
string
->
data
=
(
char
*
)
string
+
sizeof
(
ec_eeprom_string_t
);
memcpy
(
string
->
data
,
data
+
offset
+
1
,
size
);
string
->
data
[
size
]
=
0x00
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment