Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753940AbcDVOjc (ORCPT ); Fri, 22 Apr 2016 10:39:32 -0400 Received: from mxout1.idt.com ([157.165.5.25]:48551 "EHLO mxout1.idt.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751582AbcDVOja convert rfc822-to-8bit (ORCPT ); Fri, 22 Apr 2016 10:39:30 -0400 From: "Bounine, Alexandre" To: Vladimir Zapolskiy , Matt Porter CC: "linux-kernel@vger.kernel.org" , "Andrew Morton" Subject: RE: [PATCH] rapidio: fix potential NULL pointer dereference Thread-Topic: [PATCH] rapidio: fix potential NULL pointer dereference Thread-Index: AQHRnAkfjbK6CbfoY0mUbt4M0MDNQ5+WEQjA Date: Fri, 22 Apr 2016 14:39:13 +0000 Message-ID: <8D983423E7EDF846BB3056827B8CC5D15CFD3865@corpmail1.na.ads.idt.com> References: <1461269104-31000-1-git-send-email-vz@mleia.com> In-Reply-To: <1461269104-31000-1-git-send-email-vz@mleia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [157.165.140.139] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1300 Lines: 40 Thank you. Ack-ed. > -----Original Message----- > From: Vladimir Zapolskiy [mailto:vz@mleia.com] > Sent: Thursday, April 21, 2016 4:05 PM > To: Matt Porter; Bounine, Alexandre > Cc: linux-kernel@vger.kernel.org > Subject: [PATCH] rapidio: fix potential NULL pointer dereference > > The change fixes improper check for a returned error value by > class_create() function, which on error returns ERR_PTR() value, > thus the original check always results in a dead code on error path. > > Signed-off-by: Vladimir Zapolskiy > --- > drivers/rapidio/devices/rio_mport_cdev.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/rapidio/devices/rio_mport_cdev.c > b/drivers/rapidio/devices/rio_mport_cdev.c > index 5d4d918..96168b8 100644 > --- a/drivers/rapidio/devices/rio_mport_cdev.c > +++ b/drivers/rapidio/devices/rio_mport_cdev.c > @@ -2669,9 +2669,9 @@ static int __init mport_init(void) > > /* Create device class needed by udev */ > dev_class = class_create(THIS_MODULE, DRV_NAME); > - if (!dev_class) { > + if (IS_ERR(dev_class)) { > rmcd_error("Unable to create " DRV_NAME " class"); > - return -EINVAL; > + return PTR_ERR(dev_class); > } > > ret = alloc_chrdev_region(&dev_number, 0, RIO_MAX_MPORTS, > DRV_NAME); > -- > 2.1.4