linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: gregkh@suse.de (Greg KH)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] driver core: let dev_set_drvdata return int instead of void as it can fail
Date: Wed, 20 Apr 2011 09:15:13 -0700	[thread overview]
Message-ID: <20110420161513.GA25396@suse.de> (raw)
In-Reply-To: <BANLkTi=q8jfEaLByZVZPHHYp_5PTK-36cw@mail.gmail.com>

On Wed, Apr 20, 2011 at 11:09:56AM +0200, Micha? Miros?aw wrote:
> 2011/4/20 Greg KH <greg@kroah.com>:
> > On Mon, Apr 11, 2011 at 08:42:58PM +0200, Uwe Kleine-K?nig wrote:
> >> Before commit
> >>
> >> ? ? ? b402843 (Driver core: move dev_get/set_drvdata to drivers/base/dd.c)
> >>
> >> calling dev_set_drvdata with dev=NULL was an unchecked error. After some
> >> discussion about what to return in this case removing the check (and so
> >> producing a null pointer exception) seems fine.
> > I'm confused by this thread, care to resend all of these in a series
> > against the latest linux-next tree?
> 
> I'd argue that dev_set_drvdata() should never fail. All current
> drivers depend on this, and if dev_set_drvdata() fails, user will get
> an OOPS a short while after the device finishes initializing (or maybe
> even before that if callbacks are involved).
> Allowing dev_set_drvdata() to fail will need putting a lot of
> boilerplate code into drivers for no real gain.
> 
> Please consider reverting commit
> b4028437876866aba4747a655ede00f892089e14 instead of "fixing" issues it
> generates.

That patch was from 2009, surely if there were real issues with that
change, it would have shown up in the past 2 years, right?

And no, I don't want to revert that, we need that for future work in
this area.

I have no problem migrating the error code for that function on down,
very few drivers call this function directly, it should be wrapped by
bus-specific functions instead, right?  They can handle the error
handling on their own and not force the individual drivers to handle it
if needed.

Have you ever seen this function fail?

thanks,

greg k-h

  reply	other threads:[~2011-04-20 16:15 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-01  4:33 [RFC] device.h: add device_set_platdata routine Viresh Kumar
2011-03-01  7:59 ` Uwe Kleine-König
2011-03-01  8:27   ` viresh kumar
2011-03-01  9:05     ` Uwe Kleine-König
2011-03-01  9:13       ` viresh kumar
2011-03-01 15:34   ` Greg KH
2011-04-06  9:24     ` [PATCH 1/5] driver core/platform_device_add_data: set platform_data to NULL if !data Uwe Kleine-König
2011-04-11 18:50       ` Uwe Kleine-König
2011-04-11 19:07         ` Greg KH
2011-04-06  9:24     ` [PATCH 2/5] driver core/platform_device_add_data: free platform data before overwriting Uwe Kleine-König
2011-04-06  9:24     ` [PATCH 3/5] driver core/platform_device_add_resources: set resource to NULL if !res Uwe Kleine-König
2011-04-06  9:24     ` [PATCH 4/5] driver core/platform_device_add_resources: free resource before overwriting Uwe Kleine-König
2011-04-06  9:24     ` [PATCH 5/5] driver core: let dev_set_drvdata return int instead of void as it can fail Uwe Kleine-König
2011-04-06  9:36       ` Michał Mirosław
2011-04-06 11:06         ` Uwe Kleine-König
2011-04-06 11:25           ` Michał Mirosław
2011-04-11 18:42             ` [PATCH v2] " Uwe Kleine-König
2011-04-19 23:58               ` Greg KH
2011-04-20  7:42                 ` Uwe Kleine-König
2011-04-20  7:44                   ` [PATCH v2 1/5] driver core/platform_device_add_data: set platform_data to NULL if !data Uwe Kleine-König
2011-04-20  7:44                     ` [PATCH v2 2/5] driver core/platform_device_add_data: free platform data before overwriting Uwe Kleine-König
2011-04-20  7:44                     ` [PATCH v2 3/5] driver core/platform_device_add_resources: set resource to NULL if !res Uwe Kleine-König
2011-04-20  7:44                     ` [PATCH v2 4/5] driver core/platform_device_add_resources: free resource before overwriting Uwe Kleine-König
2011-04-20  7:44                     ` [PATCH v2 5/5] driver core: let dev_set_drvdata return int instead of void as it can fail Uwe Kleine-König
2011-04-29  8:12                       ` Russell King - ARM Linux
2011-04-29  9:16                         ` Uwe Kleine-König
2011-04-20 16:17                   ` [PATCH v2] " Greg KH
2011-04-20  9:09                 ` Michał Mirosław
2011-04-20 16:15                   ` Greg KH [this message]
2011-04-20 17:59                     ` Michał Mirosław
2011-04-06 10:10       ` [PATCH 5/5] " viresh kumar
2011-04-06 11:41       ` Michał Mirosław

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=20110420161513.GA25396@suse.de \
    --to=gregkh@suse.de \
    --cc=linux-arm-kernel@lists.infradead.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 NNTP newsgroup(s).