Re: [PATCH] connman : Add null check in prepare_target to avoid SIG=6

Denis Kenzior <[email protected]> Wed, 4 Jun 2025 16:30:04 -0500
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
Hi Shailesh,

On 6/2/25 1:49 AM, Shailesh Rathod/LGSI GPOS Dev wrote:
> From: Shailesh Rathod <[email protected]>
> Date: Wed, 23 Apr 2025 17:48:14 +0900
> 
> Add null check in prepare_target to avoid SIG=6
> 
> When Ethernet is connected and an attempt is made to enable the SoftAP,
> a SIGSEGV (signal 6) is observed.To prevent this, add a null check to

Can you please provide the relevant backtrace in v2?  It is hard to see what 
this patch is fixing without some more context.

> avoid the segmentation fault.

Same whitespace corruption with this patch as well:

[denkenz@archdev connman]$ git am 
~/Downloads/connman-Add-null-check-in-prepare_target-to-avoid-SIG-6.patch
Applying: connman : Add null check in prepare_target to avoid SIG=6
error: corrupt patch at line 11

> 
> Signed-off-by: Shailesh Rathod<[email protected]>
> ---
>   src/iptables.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/src/iptables.c b/src/iptables.c
> index a81a077..54e04d3 100644
> --- a/src/iptables.c
> +++ b/src/iptables.c
> @@ -2746,20 +2746,21 @@ static struct xtables_target *prepare_target(struct connman_iptables *table,
> 
>      switch (table->type) {
>      case AF_INET:
> -       if (xt_t->x6_options)
> +       if (xt_t->x6_options && xt_t->option_offset){
>              iptables_globals.opts =
>                  xtables_options_xfrm(
>                      iptables_globals.orig_opts,
>                      iptables_globals.opts,
>                      xt_t->x6_options,
>                      &xt_t->option_offset);
> -       else
> +       }else if(xt_t->extra_opts && xt_t->option_offset){

Please refer to:
https://www.kernel.org/doc/html/latest/process/coding-style.html
Section 3

>              iptables_globals.opts =
>                  xtables_merge_options(
>                      iptables_globals.orig_opts,
>                      iptables_globals.opts,
>                      xt_t->extra_opts,
>                      &xt_t->option_offset);
> +       }
> 
>          if (!iptables_globals.opts) {
>              g_free(xt_t->t);
> @@ -2768,21 +2769,21 @@ static struct xtables_target *prepare_target(struct connman_iptables *table,
> 
>          break;
>      case AF_INET6:
> -       if (xt_t->x6_options)
> +       if (xt_t->x6_options && xt_t->option_offset){
>              ip6tables_globals.opts =
>                  xtables_options_xfrm(
>                      ip6tables_globals.orig_opts,
>                      ip6tables_globals.opts,
>                      xt_t->x6_options,
>                      &xt_t->option_offset);
> -       else
> +       }else if(xt_t->extra_opts && xt_t->option_offset){
>              ip6tables_globals.opts =
>                  xtables_merge_options(
>                      ip6tables_globals.orig_opts,
>                      ip6tables_globals.opts,
>                      xt_t->extra_opts,
>                      &xt_t->option_offset);
> -
> +       }
>          if (!ip6tables_globals.opts) {
>              g_free(xt_t->t);
>              xt_t = NULL;
> 

Regards,
-Denis