On 27.03.21 11:19, Philippe Gerum wrote: > From: Philippe Gerum <[email protected]> > > Signed-off-by: Philippe Gerum <[email protected]> > --- > kernel/drivers/net/stack/ipv4/icmp.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/kernel/drivers/net/stack/ipv4/icmp.c > b/kernel/drivers/net/stack/ipv4/icmp.c > index 0671cbc93..c3563595e 100644 > --- a/kernel/drivers/net/stack/ipv4/icmp.c > +++ b/kernel/drivers/net/stack/ipv4/icmp.c > @@ -313,8 +313,17 @@ static int rt_icmp_send_request(u32 daddr, struct > icmp_bxm *icmp_param) > int rt_icmp_send_echo(u32 daddr, u16 id, u16 sequence, size_t msg_size) > { > struct icmp_bxm icmp_param; > - unsigned char pattern_buf[msg_size]; > + unsigned char *pattern_buf; > off_t pos; > + int ret; > + > + /* > + * This is ping, exec time is not that critical, so > + * rtdm_malloc() is ok for the purpose of echoing.
Solution is fine but comment is misleading: This is the submission path, not the reflection. We are setting up the ping message here, and this is indeed not time-critical. I'll fix that up on merge. > + */ > + pattern_buf = rtdm_malloc(msg_size); > + if (pattern_buf == NULL) > + return -ENOMEM; > > /* first purge any potentially pending ICMP fragments */ > rt_ip_frag_invalidate_socket(icmp_socket); > @@ -343,7 +352,10 @@ int rt_icmp_send_echo(u32 daddr, u16 id, u16 sequence, > size_t msg_size) > } > icmp_param.data.buf = pattern_buf; > > - return rt_icmp_send_request(daddr, &icmp_param); > + ret = rt_icmp_send_request(daddr, &icmp_param); > + rtdm_free(pattern_buf); > + > + return ret; > } > > /*** > Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
