From patchwork Thu Jul 7 07:40:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9217979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 482F9607D9 for ; Thu, 7 Jul 2016 07:43:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E34A2877E for ; Thu, 7 Jul 2016 07:43:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3320528782; Thu, 7 Jul 2016 07:43:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 238C02877E for ; Thu, 7 Jul 2016 07:43:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL3vf-0007uE-Cb; Thu, 07 Jul 2016 07:40:59 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL3vd-0007u2-TS for xen-devel@lists.xenproject.org; Thu, 07 Jul 2016 07:40:57 +0000 Received: from [193.109.254.147] by server-11.bemta-14.messagelabs.com id C1/00-01707-9870E775; Thu, 07 Jul 2016 07:40:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOIsWRWlGSWpSXmKPExsXS6fjDS7eDvS7 cYNMvfYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPb2m62gtOsFYuW7mRvYLzM0sXIySEkkCex rHs/O4jNK2AnMaOtB8yWEDCU2Dd/FRuIzSKgKnHg4TlGEJtNQF2i7dl21i5GDg4RgXiJx++CQ MLMAs4SG5e1s4CEhQX8Je7uKQcxeQUEJf7uEIao0JJ4+OsWC4StLbFs4WtmkBJmAWmJ5f84Jj DyzEJomIWkYRaShlkIDQsYWVYxahSnFpWlFukameslFWWmZ5TkJmbm6BoamujlphYXJ6an5iQ mFesl5+duYgQGUj0DA+MOxumX/Q4xSnIwKYny7rlbGy7El5SfUpmRWJwRX1Sak1p8iFGGg0NJ gvcha124kGBRanpqRVpmDjCkYdISHDxKIrxubEBp3uKCxNzizHSI1ClGXY4FP26vZRJiycvPS 5US59UCKRIAKcoozYMbAYuvS4yyUsK8jAwMDEI8BalFuZklqPKvGMU5GJWEeV1BpvBk5pXAbX oFdAQT0BE/XapBjihJREhJNTAeVPByC+/ov3TtMqfcjPl8PwRiT59rUJ1hvuBnjZ3adH2p7Vb /GyqEWtK1z1XkR4UvuJFv+KGM8a3E3JPTX02r9jDPZ6sXDebebLLU53eif+md049lQs9cbOLV SViw7Eb2J+Ht20VrbjnM599YtjVd7OKM+y4XOFq+Vjqd08uZvsP8g99+h2dKLMUZiYZazEXFi QCGSP/0qgIAAA== X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1467877254!43792458!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36876 invoked from network); 7 Jul 2016 07:40:56 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-11.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Jul 2016 07:40:56 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 07 Jul 2016 01:40:54 -0600 Message-Id: <577E23A602000078000FBE15@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Thu, 07 Jul 2016 01:40:54 -0600 From: "Jan Beulich" To: "Roger Pau Monne" , "Konrad Rzeszutek Wilk" Mime-Version: 1.0 Content-Disposition: inline Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH] xen-blkfront: avoid NULL de-reference in CDROM ioctl handling X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The ioctl can be called prior to full device setup having completed. Signed-off-by: Jan Beulich --- drivers/block/xen-blkfront.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- 4.7-rc6-xen.orig/drivers/block/xen-blkfront.c +++ 4.7-rc6-xen/drivers/block/xen-blkfront.c @@ -496,12 +496,10 @@ static int blkif_ioctl(struct block_devi return -EFAULT; return 0; - case CDROM_GET_CAPABILITY: { - struct gendisk *gd = info->gd; - if (gd->flags & GENHD_FL_CD) + case CDROM_GET_CAPABILITY: + if (info->gd && (info->gd->flags & GENHD_FL_CD)) return 0; return -EINVAL; - } default: /*printk(KERN_ALERT "ioctl %08x not supported by Xen blkdev\n",