public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexandra Winter <wintera@linux.ibm.com>
To: Suman Ghosh <sumang@marvell.com>,
	Markus Elfring <Markus.Elfring@web.de>,
	"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Wenjia Zhang <wenjia@linux.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [EXT] Re: [PATCH 1/2] net/iucv: Improve unlocking in iucv_enable()
Date: Tue, 2 Jan 2024 10:53:15 +0100	[thread overview]
Message-ID: <2bf1b0cb-86af-4e00-a0aa-23e3944617a2@linux.ibm.com> (raw)
In-Reply-To: <SJ0PR18MB52168AC4B874C0B99BD37039DB61A@SJ0PR18MB5216.namprd18.prod.outlook.com>



On 02.01.24 09:27, Suman Ghosh wrote:
>>> [Suman] This looks confusing. What is the issue with retaining the
>> original change?
>>
>> I propose to reduce the number of cpus_read_unlock() calls (in the
>> source code).
>>
>> Regards,
>> Markus
> [Suman] Then I think we should do something like this. Changing the code flow back-and-forth using "goto" does not seem correct.

I share Suman's concern that jumping backwards goto is confusing.
But I think the Coccinelle finding of freeing a null-pointer should be addressed (see patch 2/2)
Thank you Markus for reporting it.

The allocation does require holding the cpus_read_lock. 
For some reason Markus wants to reduce the number of cpus_read_unlock() calls (why?),
so what about something like this for both issues:

diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index 0ed6e34d6edd..1030403b826b 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -542,24 +542,22 @@ static int iucv_enable(void)
        size_t alloc_size;
        int cpu, rc;

-       cpus_read_lock();
-       rc = -ENOMEM;
        alloc_size = iucv_max_pathid * sizeof(struct iucv_path);
        iucv_path_table = kzalloc(alloc_size, GFP_KERNEL);
        if (!iucv_path_table)
-               goto out;
+               return -ENOMEM;
        /* Declare per cpu buffers. */
-       rc = -EIO;
+       cpus_read_lock();
        for_each_online_cpu(cpu)
                smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
-       if (cpumask_empty(&iucv_buffer_cpumask))
+       if (cpumask_empty(&iucv_buffer_cpumask)) {
                /* No cpu could declare an iucv buffer. */
-               goto out;
-       cpus_read_unlock();
-       return 0;
-out:
-       kfree(iucv_path_table);
-       iucv_path_table = NULL;
+               kfree(iucv_path_table);
+               iucv_path_table = NULL;
+               rc = -EIO;
+       } else {
+               rc = 0;
+       }
        cpus_read_unlock();
        return rc;
 }

  reply	other threads:[~2024-01-02  9:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-01 20:56 [PATCH 0/2] net/iucv: Adjustments for iucv_enable() Markus Elfring
2024-01-01 20:58 ` [PATCH 1/2] net/iucv: Improve unlocking in iucv_enable() Markus Elfring
2024-01-02  6:44   ` [EXT] " Suman Ghosh
2024-01-02  7:38     ` Markus Elfring
2024-01-02  8:27       ` [EXT] " Suman Ghosh
2024-01-02  9:53         ` Alexandra Winter [this message]
2024-01-02 10:31           ` Markus Elfring
2024-01-01 21:00 ` [PATCH 2/2] net/iucv: Improve error handling " Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2bf1b0cb-86af-4e00-a0aa-23e3944617a2@linux.ibm.com \
    --to=wintera@linux.ibm.com \
    --cc=Markus.Elfring@web.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sumang@marvell.com \
    --cc=wenjia@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox