mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Zheyu Ma <zheyuma97@gmail.com>, gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] tty: serial: jsm: allocate queue buffer at probe time
Date: Wed, 7 Jul 2021 09:49:38 +0200	[thread overview]
Message-ID: <fde46fee-fad9-8f3b-79b0-ad426fd379dd@kernel.org> (raw)
In-Reply-To: <1625489588-26079-1-git-send-email-zheyuma97@gmail.com>

On 05. 07. 21, 14:53, Zheyu Ma wrote:
> In function 'neo_intr', the driver uses 'ch->ch_equeue' and
> 'ch->ch_reuque'. These two pointers are initialized in 'jsm_tty_open',
> but the interrupt handler 'neo_intr' has been registered in the probe
> progress. If 'jsm_tty_open' has not been called at this time, it will
> cause null pointer dereference.
> 
> Once the driver registers the interrupt handler, the driver should be
> ready to handle it.
> 
> Fix this by allocating the memory at probe time and not at open time.

You are allocating the buffer in jsm_tty_init now. But that is still 
called after request_irq() in probe. So care to explain how this helps 
exactly? As I understand it, you only made the window much smaller.

Anyway, I'm no expert on jsm, but AFAICS jsm_tty_open first allocates 
the buffers, brd->bd_ops->uart_init() / neo_uart_init() clears ier and 
only brd->bd_ops->param() / neo_param() enables interrupts on the device 
(by ier update and write). So how it comes an interrupt came before 
neo_param() in jsm_tty_open was called?

> This log reveals it:
> 
> [   12.771912] BUG: kernel NULL pointer dereference, address: 0000000000000000
> [   12.774932] #PF: supervisor write access in kernel mode
> [   12.775314] #PF: error_code(0x0002) - not-present page
> [   12.775689] PGD 0 P4D 0
> [   12.775881] Oops: 0002 [#1] PREEMPT SMP PTI
> [   12.776212] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 5.12.4-g70e7f0549188-dirty #106
> [   12.776803] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
> [   12.777627] RIP: 0010:memcpy_fromio+0x75/0xa0
> [   12.777983] Code: e9 02 f3 a5 41 f6 c5 02 74 02 66 a5 41 f6 c5 01 74 01 a4 e8 5d 4e 6b ff 5b 41 5c 41 5d 5d c3 e8 51 4e 6b ff 4c 89 e7 48 89 de <a4> 49 89 fc 48 89 f3 49 83 ed 01 eb a4 e8 39 4e 6b ff 4c 89 e7 48
> [   12.779377] RSP: 0018:ffffc90000118db0 EFLAGS: 00010046
> [   12.779771] RAX: ffff888100258000 RBX: ffffc90007d0010f RCX: 0000000000000000
> [   12.780298] RDX: 0000000000000000 RSI: ffffc90007d0010f RDI: 0000000000000000
> [   12.780820] RBP: ffffc90000118dc8 R08: 0000000000000000 R09: 0000000000000000
> [   12.781359] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000
> [   12.781928] R13: 0000000000000001 R14: 0000000007d0009e R15: 0000000000000000
> [   12.782453] FS:  0000000000000000(0000) GS:ffff88817bc80000(0000) knlGS:0000000000000000
> [   12.783067] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   12.783499] CR2: 0000000000000000 CR3: 0000000005e2e000 CR4: 00000000000006e0
> [   12.784051] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [   12.784579] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> [   12.785105] Call Trace:
> [   12.785295]  <IRQ>
> [   12.785457]  neo_copy_data_from_uart_to_queue+0x2f7/0x4e0
> [   12.785871]  neo_parse_isr.part.4+0x175/0x4d0
> [   12.786217]  neo_intr+0x188/0x7a0
thanks,
-- 
-- 
js
suse labs

  reply	other threads:[~2021-07-07  7:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 12:53 Zheyu Ma
2021-07-07  7:49 ` Jiri Slaby [this message]
2021-07-07 12:28   ` Zheyu Ma
2021-07-07 12:52   ` Andy Shevchenko
2021-07-07 19:13     ` Jiri Slaby
2021-07-09 14:00       ` Zheyu Ma
2021-07-09 14:20         ` Greg Kroah-Hartman
2021-07-09 14:55           ` Zheyu Ma
     [not found] ` <CAHp75Vdne2fVAdmMYPn71T8LnSNMxVhBVK8dbmMASTSTUnOjBA@mail.gmail.com>
2021-07-07 10:37   ` Zheyu Ma

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=fde46fee-fad9-8f3b-79b0-ad426fd379dd@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=zheyuma97@gmail.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

all inboxes | Powered by JetHome®