mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Joshua Thompson <funaho@jurai.org>,
	linux-m68k <linux-m68k@lists.linux-m68k.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-ide@vger.kernel.org
Subject: Re: [PATCH v2] ide/macide: Convert Mac IDE driver to platform driver
Date: Wed, 16 Sep 2020 08:56:58 +1000 (AEST)	[thread overview]
Message-ID: <alpine.LNX.2.23.453.2009160758350.6@nippy.intranet> (raw)
In-Reply-To: <CAMuHMdX1GXMGg1mviE_msM1vx0ZLEKEPT4AacSBjYDzN6sZVmw@mail.gmail.com>

On Tue, 15 Sep 2020, Geert Uytterhoeven wrote:

> > > > --- a/drivers/ide/macide.c
> > > > +++ b/drivers/ide/macide.c
> > >
> > > > @@ -109,42 +110,61 @@ static const char *mac_ide_name[] =
> > > >   * Probe for a Macintosh IDE interface
> > > >   */
> > > >
> > > > -static int __init macide_init(void)
> > > > +static int mac_ide_probe(struct platform_device *pdev)
> > > >  {
> > >
> > > >         printk(KERN_INFO "ide: Macintosh %s IDE controller\n",
> > > >                          mac_ide_name[macintosh_config->ide_type - 1]);
> > > >
> > > > -       macide_setup_ports(&hw, base, irq);
> > > > +       macide_setup_ports(&hw, mem->start, irq->start);
> > > >
> > > > -       return ide_host_add(&d, hws, 1, NULL);
> > > > +       rc = ide_host_add(&d, hws, 1, &host);
> > > > +       if (rc)
> > > > +               return rc;
> > > > +
> > > > +       platform_set_drvdata(pdev, host);
> > >
> > > Move one up, to play it safe?
> > >
> >
> > You mean, before calling ide_host_add? The 'host' pointer is uninitialized
> > prior to that call.
> 
> Oh right, so the IDE subsystem doesn't let you use the drvdata inside 
> your driver (besides in remove()) in a safe way :-(
> 

The IDE subsystem does allow other patterns here. I could have changed 
ide_host_alloc() into ide_host_register() followed by ide_host_add() but I 
could not see any benefit from that change.

A quick search for "platform_device" shows that the driver does not use 
any uninitialized driver_data pointer (because ide_ifr is a global). In 
your message of September 9th you readily reached the same conclusion when 
you reviewed v1.

If mac_ide_probe() followed the usual pattern it might make review easier 
(as reviewers may not wish to consider the entire driver) but does that 
really make the code more "safe"?

  reply	other threads:[~2020-09-15 22:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14  2:42 Finn Thain
2020-09-14 11:42 ` Geert Uytterhoeven
2020-09-15  1:17   ` Finn Thain
2020-09-15  7:15     ` Geert Uytterhoeven
2020-09-15 22:56       ` Finn Thain [this message]
2020-09-24  1:07         ` Finn Thain
2020-09-24  1:29           ` Michael Schmitz
2020-09-24  7:21           ` Geert Uytterhoeven

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=alpine.LNX.2.23.453.2009160758350.6@nippy.intranet \
    --to=fthain@telegraphics.com.au \
    --cc=b.zolnierkie@samsung.com \
    --cc=davem@davemloft.net \
    --cc=funaho@jurai.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.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

all inboxes | Powered by JetHome®