stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Colin Ian King <colin.king@canonical.com>,
	Felipe Balbi <felipe.balbi@linux.intel.com>,
	Sasha Levin <alexander.levin@microsoft.com>
Subject: [PATCH 4.4 53/67] usb: gadget: dont dereference g until after it has been null checked
Date: Fri,  2 Feb 2018 17:58:22 +0100	[thread overview]
Message-ID: <20180202140821.185771025@linuxfoundation.org> (raw)
In-Reply-To: <20180202140815.091718203@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Colin Ian King <colin.king@canonical.com>


[ Upstream commit b2fc059fa549fe6881d4c1f8d698b0f50bcd16ec ]

Avoid dereferencing pointer g until after g has been sanity null checked;
move the assignment of cdev much later when it is required into a more
local scope.

Detected by CoverityScan, CID#1222135 ("Dereference before null check")

Fixes: b785ea7ce662 ("usb: gadget: composite: fix ep->maxburst initialization")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/gadget/composite.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -104,7 +104,6 @@ int config_ep_by_speed(struct usb_gadget
 			struct usb_function *f,
 			struct usb_ep *_ep)
 {
-	struct usb_composite_dev	*cdev = get_gadget_data(g);
 	struct usb_endpoint_descriptor *chosen_desc = NULL;
 	struct usb_descriptor_header **speed_desc = NULL;
 
@@ -176,8 +175,12 @@ ep_found:
 			_ep->maxburst = comp_desc->bMaxBurst + 1;
 			break;
 		default:
-			if (comp_desc->bMaxBurst != 0)
+			if (comp_desc->bMaxBurst != 0) {
+				struct usb_composite_dev *cdev;
+
+				cdev = get_gadget_data(g);
 				ERROR(cdev, "ep0 bMaxBurst must be 0\n");
+			}
 			_ep->maxburst = 1;
 			break;
 		}

  parent reply	other threads:[~2018-02-02 17:01 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 16:57 [PATCH 4.4 00/67] 4.4.115-stable review Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 02/67] bpf: fix branch pruning logic Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 03/67] x86: bpf_jit: small optimization in emit_bpf_tail_call() Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 04/67] bpf: fix bpf_tail_call() x64 JIT Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 05/67] bpf: introduce BPF_JIT_ALWAYS_ON config Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 06/67] bpf: arsh is not supported in 32 bit alu thus reject it Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 07/67] bpf: avoid false sharing of map refcount with max_entries Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 08/67] bpf: fix divides by zero Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 09/67] bpf: fix 32-bit divide " Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 10/67] bpf: reject stores into ctx via st and xadd Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 11/67] x86/pti: Make unpoison of pgd for trusted boot work for real Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 13/67] ALSA: seq: Make ioctls race-free Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 14/67] crypto: aesni - handle zero length dst buffer Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 15/67] crypto: af_alg - whitelist mask and type Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 16/67] power: reset: zx-reboot: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 17/67] gpio: iop: " Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 18/67] gpio: ath79: add missing MODULE_DESCRIPTION/LICENSE Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 19/67] mtd: nand: denali_pci: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 20/67] igb: Free IRQs when device is hotplugged Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 27/67] ACPI / bus: Leave modalias empty for devices which are not present Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 28/67] cpufreq: Add Loongson machine dependencies Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 29/67] bcache: check return value of register_shrinker Greg Kroah-Hartman
2018-02-02 16:57 ` [PATCH 4.4 30/67] drm/amdgpu: Fix SDMA load/unload sequence on HWS disabled mode Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 31/67] drm/amdkfd: Fix SDMA ring buffer size calculation Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 32/67] drm/amdkfd: Fix SDMA oversubsription handling Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 33/67] openvswitch: fix the incorrect flow action alloc size Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 34/67] mac80211: fix the update of path metric for RANN frame Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 35/67] btrfs: fix deadlock when writing out space cache Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 37/67] xen-netfront: remove warning when unloading module Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 38/67] nfsd: CLOSE SHOULD return the invalid special stateid for NFSv4.x (x>0) Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 39/67] nfsd: Ensure we check stateid validity in the seqid operation checks Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 40/67] grace: replace BUG_ON by WARN_ONCE in exit_net hook Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 41/67] nfsd: check for use of the closed special stateid Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 42/67] lockd: fix "list_add double add" caused by legacy signal interface Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 43/67] hwmon: (pmbus) Use 64bit math for DIRECT format values Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 44/67] net: ethernet: xilinx: Mark XILINX_LL_TEMAC broken on 64-bit Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 45/67] quota: Check for register_shrinker() failure Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 46/67] SUNRPC: Allow connect to return EHOSTUNREACH Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 47/67] kmemleak: add scheduling point to kmemleak_scan() Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 48/67] drm/omap: Fix error handling path in omap_dmm_probe() Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 49/67] xfs: ubsan fixes Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 50/67] scsi: aacraid: Prevent crash in case of free interrupt during scsi EH path Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 51/67] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 52/67] media: usbtv: add a new usbid Greg Kroah-Hartman
2018-02-02 16:58 ` Greg Kroah-Hartman [this message]
2018-02-02 16:58 ` [PATCH 4.4 54/67] staging: rtl8188eu: Fix incorrect response to SIOCGIWESSID Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 55/67] usb: option: Add support for FS040U modem Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 57/67] USB: cdc-acm: Do not log urb submission errors on disconnect Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 58/67] CDC-ACM: apply quirk for card reader Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 59/67] USB: serial: io_edgeport: fix possible sleep-in-atomic Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 60/67] usbip: prevent bind loops on devices attached to vhci_hcd Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 61/67] usbip: list: dont list " Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 62/67] USB: serial: simple: add Motorola Tetra driver Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 63/67] usb: f_fs: Prevent gadget unbind if it is already unbound Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 64/67] usb: uas: unconditionally bring back host after reset Greg Kroah-Hartman
2018-03-03  0:19   ` Ben Hutchings
2018-03-03  9:14     ` Hans de Goede
2018-02-02 16:58 ` [PATCH 4.4 65/67] selinux: general protection fault in sock_has_perm Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 66/67] serial: imx: Only wakeup via RTSDEN bit if the system has RTS/CTS Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.4 67/67] spi: imx: do not access registers while clocks disabled Greg Kroah-Hartman
2018-02-02 18:40 ` [PATCH 4.4 00/67] 4.4.115-stable review Nathan Chancellor
2018-02-03  5:18   ` Greg Kroah-Hartman
2018-02-02 22:20 ` Shuah Khan
2018-02-02 22:33 ` Dan Rue
2018-02-03 15:28 ` Guenter Roeck
2018-02-03 15:44   ` Greg Kroah-Hartman

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=20180202140821.185771025@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.levin@microsoft.com \
    --cc=colin.king@canonical.com \
    --cc=felipe.balbi@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).