Linux-Modules Archive mirror
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arnd Bergmann" <arnd@kernel.org>
Cc: "Luis Chamberlain" <mcgrof@kernel.org>,
	linux-modules@vger.kernel.org,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] module: don't ignore sysfs_create_link() failures
Date: Tue, 26 Mar 2024 15:12:46 +0100	[thread overview]
Message-ID: <5fb74d31-a5f7-4fc0-96f0-f69158829df3@app.fastmail.com> (raw)
In-Reply-To: <2024032349-corporate-detached-0dc9@gregkh>

On Sat, Mar 23, 2024, at 17:50, Greg Kroah-Hartman wrote:
> On Fri, Mar 22, 2024 at 06:39:11PM +0100, Arnd Bergmann wrote:
>> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
>> index daee55c9b2d9..7ef75b60d331 100644
>> --- a/drivers/base/bus.c
>> +++ b/drivers/base/bus.c
>> @@ -674,7 +674,12 @@ int bus_add_driver(struct device_driver *drv)
>>  		if (error)
>>  			goto out_del_list;
>>  	}
>> -	module_add_driver(drv->owner, drv);
>> +	error = module_add_driver(drv->owner, drv);
>> +	if (error) {
>> +		printk(KERN_ERR "%s: failed to create module links for %s\n",
>> +			__func__, drv->name);
>> +		goto out_del_list;
>
> Don't we need to walk back the driver_attach() call here if this fails?

Yes, fixed now. There are still some other calls right after
it that print an error but don't cause bus_add_driver() to fail
though. We may want to add similar unwinding there, but that
feels like it should be a separate patch.

>>  
>>  	if (!mk)
>> -		return;
>> +		return 0;
>> +
>> +	ret = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module");
>> +	if (ret && ret != -EEXIST)
>
> Why would EEXIST happen here?  How can this be called twice?
>

My impression was that the lack of error handling and the
comment was ab out a case where that might happen
intentionally. I've removed it now as I couldn't find any
evidence that this is really needed. I suppose we would
find out in testing if we do.

     Arnd

      reply	other threads:[~2024-03-26 14:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 17:39 [PATCH] [v2] module: don't ignore sysfs_create_link() failures Arnd Bergmann
2024-03-23 16:50 ` Greg Kroah-Hartman
2024-03-26 14:12   ` Arnd Bergmann [this message]

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=5fb74d31-a5f7-4fc0-96f0-f69158829df3@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=rafael@kernel.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).