mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Harish Jenny K N <harish_kandiga@mentor.com>
To: Felipe Balbi <balbi@kernel.org>
Cc: <linux-usb@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-kernel@vger.kernel.org>,
	Jim Baxter <jim_baxter@mentor.com>
Subject: [PATCH v1 1/1] usb: gadget: f_fs: Stop ffs_closed NULL pointers.
Date: Thu, 8 Sep 2016 11:18:16 +0200	[thread overview]
Message-ID: <1473326296-23987-2-git-send-email-harish_kandiga@mentor.com> (raw)
In-Reply-To: <1473326296-23987-1-git-send-email-harish_kandiga@mentor.com>

From: Jim Baxter <jim_baxter@mentor.com>

The struct ffs_data::private_data has a pointer to
ffs_dev stored in it during the ffs_fs_mount() function
however it is not cleared when the ffs_dev is freed
later which causes the ffs_closed function to crash
with "Unable to handle kernel NULL pointer dereference"
error when using the data in ffs_data::private_data.

This clears this pointer during the ffs_free_dev clean
up function.

Signed-off-by: Jim Baxter <jim_baxter@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com>
---
 drivers/usb/gadget/function/f_fs.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 5c8429f..b309650 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3470,6 +3470,11 @@ static void _ffs_free_dev(struct ffs_dev *dev)
 	list_del(&dev->entry);
 	if (dev->name_allocated)
 		kfree(dev->name);
+
+	/* Clear the private_data pointer to stop incorrect dev access */
+	if (dev->ffs_data)
+		dev->ffs_data->private_data = NULL;
+
 	kfree(dev);
 	if (list_empty(&ffs_devices))
 		functionfs_cleanup();
-- 
1.7.9.5

  reply	other threads:[~2016-09-08  9:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Harish Jenny K N <harish_kandiga@mentor.com>
2016-09-08  9:18 ` [PATCH v1 0/1] " Harish Jenny K N
2016-09-08  9:18   ` Harish Jenny K N [this message]
2016-09-09  9:30 ` [PATCH v1 0/2] usb: gadget: NCM: NULL pointer dereference in eth_start_xmit Harish Jenny K N
2016-09-09  9:30   ` [PATCH v1 1/2] usb: gadget: u_ether: fix another dereference after null check Harish Jenny K N
2016-09-10  3:39     ` Peter Chen
2016-09-09  9:30   ` [PATCH v1 2/2] usb: gadget: NCM: Protect dev->port_usb using dev->lock Harish Jenny K N
2016-09-15 14:22 ` [PATCH v1 0/3] Usb gadget ncm code cleanup Harish Jenny K N
2016-09-15 14:22   ` [PATCH v1 1/3] usb: gadget: NCM: link socket buffers to the device for tx packets Harish Jenny K N
2016-09-15 14:22   ` [PATCH v1 2/3] usb: gadget: NCM: link socket buffers to the device for received packets Harish Jenny K N
2016-09-15 18:35     ` Yauheni Kaliuta
2016-09-16  9:54       ` Harish Jenny K N
2016-09-15 14:22   ` [PATCH v1 3/3] usb: gadget: NCM: differentiate consumed packets from dropped packets Harish Jenny K N
2016-09-19  8:05 ` [PATCH v2 0/3] Usb gadget ncm code cleanup Harish Jenny K N
2016-09-19  8:05   ` [PATCH v2 1/3] usb: gadget: NCM: link socket buffers to the device for tx packets Harish Jenny K N
2016-09-19  8:05   ` [PATCH v2 2/3] usb: gadget: u_ether: link socket buffers to the device for received packets Harish Jenny K N
2016-09-19  8:05   ` [PATCH v2 3/3] usb: gadget: NCM: differentiate consumed packets from dropped packets Harish Jenny K N

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=1473326296-23987-2-git-send-email-harish_kandiga@mentor.com \
    --to=harish_kandiga@mentor.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jim_baxter@mentor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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

all inboxes | Powered by JetHome®