public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Hounschell <markh@compro.net>
To: Daeseok Youn <daeseok.youn@gmail.com>, lidza.louina@gmail.com
Cc: gregkh@linuxfoundation.org,
	driverdev-devel@linuxdriverproject.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: dgap: introduce dgap_cleanup_nodes()
Date: Thu, 17 Jul 2014 09:27:58 -0400	[thread overview]
Message-ID: <53C7CF5E.50506@compro.net> (raw)
In-Reply-To: <1498242287.361986.1405561014562.JavaMail.root@mx2.compro.net>

On 07/16/2014 09:35 PM, Daeseok Youn wrote:
> When a configration file is parsed with dgap_parsefile(),
> makes nodes for saving configrations for board.
> 
> Making a node will allocate node memory and strings for saving
> configrations with kstrdup().
> 
> So these are freed when dgap is unloaded or failed to initialize.
> 
> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> ---
> Mark, please review this patch.
> Thanks.
> 
>   drivers/staging/dgap/dgap.c |   47 +++++++++++++++++++++++++++++++++++++++++++
>   1 files changed, 47 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
> index 06c55cb..e9df2ea 100644
> --- a/drivers/staging/dgap/dgap.c
> +++ b/drivers/staging/dgap/dgap.c
> @@ -201,6 +201,7 @@ static int dgap_test_fep(struct board_t *brd);
>   static int dgap_tty_register_ports(struct board_t *brd);
>   static int dgap_firmware_load(struct pci_dev *pdev, int card_type,
>   			      struct board_t *brd);
> +static void dgap_cleanup_nodes(void);
>   
>   static void dgap_cleanup_module(void);
>   
> @@ -619,6 +620,7 @@ unregister_tty:
>   free_flipbuf:
>   	dgap_free_flipbuf(brd);
>   cleanup_brd:
> +	dgap_cleanup_nodes();
>   	dgap_release_remap(brd);
>   	kfree(brd);
>   
> @@ -659,6 +661,8 @@ static void dgap_cleanup_module(void)
>   		dgap_cleanup_board(dgap_board[i]);
>   	}
>   
> +	dgap_cleanup_nodes();
> +
>   	if (dgap_numboards)
>   		pci_unregister_driver(&dgap_driver);
>   }
> @@ -6323,6 +6327,49 @@ static void dgap_remove_tty_sysfs(struct device *c)
>   	sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group);
>   }
>   
> +static void dgap_cleanup_nodes(void)
> +{
> +	struct cnode *p;
> +
> +	p = &dgap_head;
> +
> +	while (p) {
> +		struct cnode *tmp = p->next;
> +
> +		switch (p->type) {
> +		case BNODE:
> +			kfree(p->u.board.portstr);
> +			kfree(p->u.board.addrstr);
> +			kfree(p->u.board.pcibusstr);
> +			kfree(p->u.board.pcislotstr);
> +			kfree(p->u.board.method);
> +			break;
> +		case CNODE:
> +			kfree(p->u.conc.id);
> +			kfree(p->u.conc.connect);
> +			break;
> +		case MNODE:
> +			kfree(p->u.module.id);
> +			break;
> +		case TNODE:
> +			kfree(p->u.ttyname);
> +			break;
> +		case CUNODE:
> +			kfree(p->u.cuname);
> +			break;
> +		case LNODE:
> +			kfree(p->u.line.cable);
> +			break;
> +		case PNODE:
> +			kfree(p->u.printname);
> +			break;
> +		}
> +
> +		kfree(p->u.board.status);
> +		kfree(p);
> +		p = tmp;
> +	}
> +}
>   /*
>    * Parse a configuration file read into memory as a string.
>    */
> 

I get a kernel oops when unloading the driver with this patch.

2014-07-17T09:22:12.666987-04:00 harley kernel: [60216.979134] task: ffff8801037846b0 ti: ffff880149256000 task.ti: ffff880149256000
2014-07-17T09:22:12.666988-04:00 harley kernel: [60216.979136] RIP: 0010:[<ffffffff8034d5ff>]  [<ffffffff8034d5ff>] kfree+0x17f/0x190
2014-07-17T09:22:12.666989-04:00 harley kernel: [60216.979143] RSP: 0018:ffff880149257e78  EFLAGS: 00010246
2014-07-17T09:22:12.666991-04:00 harley kernel: [60216.979144] RAX: 4000000000080068 RBX: ffffffffa0428d20 RCX: 00000000038eb895
2014-07-17T09:22:12.666992-04:00 harley kernel: [60216.979146] RDX: 4000000000080068 RSI: ffffea0004131e00 RDI: ffffffffa0428d20
2014-07-17T09:22:12.666993-04:00 harley kernel: [60216.979147] RBP: ffff880149257e90 R08: 0000000000015b60 R09: ffff88014fd55b60
2014-07-17T09:22:12.666994-04:00 harley kernel: [60216.979149] R10: ffffea0000810a00 R11: ffffffffa0424ffd R12: ffff88005a3d2a80
2014-07-17T09:22:12.666995-04:00 harley kernel: [60216.979150] R13: ffffffffa041c155 R14: 0000000000000002 R15: 0000000000000bc0
2014-07-17T09:22:12.666996-04:00 harley kernel: [60216.979152] FS:  00007fb7d51d2700(0000) GS:ffff88014fd40000(0000) knlGS:0000000000000000
2014-07-17T09:22:12.666997-04:00 harley kernel: [60216.979154] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
2014-07-17T09:22:12.666998-04:00 harley kernel: [60216.979155] CR2: 00007fe66ee4e000 CR3: 00000001497af000 CR4: 00000000000407e0
2014-07-17T09:22:12.666999-04:00 harley kernel: [60216.979156] Stack:
2014-07-17T09:22:12.667000-04:00 harley kernel: [60216.979157]  ffffffffa0428d20 ffff88005a3d2a80 ffff8801259dd330 ffff880149257eb0
2014-07-17T09:22:12.667001-04:00 harley kernel: [60216.979161]  ffffffffa041c155 0000000000000700 ffff8801259dd000 ffff880149257ee8
2014-07-17T09:22:12.667002-04:00 harley kernel: [60216.979164]  ffffffffa0424ee8 0000000000000000 ffffffff80c92700 ffffffffa04289e0
2014-07-17T09:22:12.667002-04:00 harley kernel: [60216.979167] Call Trace:
2014-07-17T09:22:12.667003-04:00 harley kernel: [60216.979172]  [<ffffffffa041c155>] dgap_cleanup_nodes+0x45/0xb0 [dgap]
2014-07-17T09:22:12.667004-04:00 harley kernel: [60216.979176]  [<ffffffffa0424ee8>] dgap_cleanup_module+0x3a8/0x4e0 [dgap]
2014-07-17T09:22:12.667005-04:00 harley kernel: [60216.979180]  [<ffffffff802b1d9f>] SyS_delete_module+0x15f/0x220
2014-07-17T09:22:12.667006-04:00 harley kernel: [60216.979183]  [<ffffffff803326c4>] ? vm_munmap+0x54/0x70
2014-07-17T09:22:12.667007-04:00 harley kernel: [60216.979186]  [<ffffffff80787b62>] system_call_fastpath+0x16/0x1b
2014-07-17T09:22:12.667008-04:00 harley kernel: [60216.979188] Code: 42 00 e9 65 ff ff ff 49 f7 02 00 c0 00 00 74 1b 49 8b 02 31 f6 f6 c4 40 74 04 41 8b 72 68 4c 89 d7 e8 f6 e8 fb ff e9 41 ff ff ff <0f> 0b 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 
2014-07-17T09:22:12.667009-04:00 harley kernel: [60216.979211] RIP  [<ffffffff8034d5ff>] kfree+0x17f/0x190
2014-07-17T09:22:12.667010-04:00 harley kernel: [60216.979214]  RSP <ffff880149257e78>
2014-07-17T09:22:12.667011-04:00 harley kernel: [60216.979216] ---[ end trace bbd37a5663615b1c ]---

Regards
Mark

       reply	other threads:[~2014-07-17 13:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1498242287.361986.1405561014562.JavaMail.root@mx2.compro.net>
2014-07-17 13:27 ` Mark Hounschell [this message]
2014-07-18  1:07   ` [PATCH] staging: dgap: introduce dgap_cleanup_nodes() DaeSeok Youn
2014-07-17  1:35 Daeseok Youn

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=53C7CF5E.50506@compro.net \
    --to=markh@compro.net \
    --cc=daeseok.youn@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lidza.louina@gmail.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox