All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@baylibre.com>
To: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	linux-serial <linux-serial@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	linux-samsung-soc@vger.kernel.org,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] serial: samsung: Fix ERR pointer dereference on deferred probe
Date: Wed, 1 Jun 2016 14:27:08 -0700	[thread overview]
Message-ID: <CAOi56cWFkdHRufaJEgYq6+ERUZXEdteeJX3+5RzVPCKmBSWFcg@mail.gmail.com> (raw)
In-Reply-To: <46dcde4f-2be6-d633-ad0b-23aa8f684ff6@osg.samsung.com>

Hi Krzysztof,

On Wed, Jun 1, 2016 at 1:57 PM, Javier Martinez Canillas
<javier@osg.samsung.com> wrote:
> Hello Krzysztof,
>
> On 05/31/2016 10:00 AM, Krzysztof Kozlowski wrote:
>> When the clk_get() of "uart" clock returns EPROBE_DEFER, the next re-probe
>> finishes with success but uses invalid (ERR_PTR) values.  This leads to
>> dereferencing of ERR_PTR stored under ourport->clk:
>>
>>       12c30000.serial: Controller clock not found
>>       (...)
>>       12c30000.serial: ttySAC3 at MMIO 0x12c30000 (irq = 61, base_baud = 0) is a S3C6400/10
>>       Unable to handle kernel paging request at virtual address fffffdfb
>>
>>       (clk_prepare) from [<c039f7d0>] (s3c24xx_serial_pm+0x20/0x128)
>>       (s3c24xx_serial_pm) from [<c0395414>] (uart_change_pm+0x38/0x40)
>>       (uart_change_pm) from [<c039689c>] (uart_add_one_port+0x31c/0x44c)
>>       (uart_add_one_port) from [<c03a035c>] (s3c24xx_serial_probe+0x2a8/0x418)
>>       (s3c24xx_serial_probe) from [<c03ee110>] (platform_drv_probe+0x50/0xb0)
>>       (platform_drv_probe) from [<c03ecb44>] (driver_probe_device+0x1f4/0x2b0)
>>       (driver_probe_device) from [<c03eb0c0>] (bus_for_each_drv+0x44/0x8c)
>>       (bus_for_each_drv) from [<c03ec8c8>] (__device_attach+0x9c/0x100)
>>       (__device_attach) from [<c03ebf54>] (bus_probe_device+0x84/0x8c)
>>       (bus_probe_device) from [<c03ec388>] (deferred_probe_work_func+0x60/0x8c)
>>       (deferred_probe_work_func) from [<c012fee4>] (process_one_work+0x120/0x328)
>>       (process_one_work) from [<c0130150>] (worker_thread+0x2c/0x4ac)
>>       (worker_thread) from [<c0135320>] (kthread+0xd8/0xf4)
>>       (kthread) from [<c0107978>] (ret_from_fork+0x14/0x3c)
>>
>> The first unsuccessful clk_get() causes s3c24xx_serial_init_port() to
>> exit with failure but the s3c24xx_uart_port is left half-configured
>> (e.g. port->mapbase is set, clk contains ERR_PTR).  On next re-probe,
>> the function s3c24xx_serial_init_port() will exit early with success
>> because of configured port->mapbase and driver will use old values,
>> including the ERR_PTR as clock.
>>
>> Fix this by cleaning the port->mapbase on error path so each re-probe
>> will initialize all of the port settings.
>>
>> Fixes: 60e93575476f ("serial: samsung: enable clock before clearing pending interrupts during init")
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
>>
>> ---
>>
>
> Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
> Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>

Tested-by: Kevin Hilman <khilman@baylibre.com>

I verified that this patch fixes a the boot regression I found in
linux-next on the exynos5410-odroidxu.

Thanks,

Kevin

      reply	other threads:[~2016-06-01 21:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31 14:00 [PATCH v2 1/2] serial: samsung: Fix ERR pointer dereference on deferred probe Krzysztof Kozlowski
2016-05-31 14:00 ` [PATCH v2 2/2] serial: samsung: Fix possible out of bounds access on non-DT platform Krzysztof Kozlowski
2016-06-01 20:57 ` [PATCH v2 1/2] serial: samsung: Fix ERR pointer dereference on deferred probe Javier Martinez Canillas
2016-06-01 21:27   ` Kevin Hilman [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=CAOi56cWFkdHRufaJEgYq6+ERUZXEdteeJX3+5RzVPCKmBSWFcg@mail.gmail.com \
    --to=khilman@baylibre.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=javier@osg.samsung.com \
    --cc=jslaby@suse.com \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=stable@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.