From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751358AbcGNMrP (ORCPT ); Thu, 14 Jul 2016 08:47:15 -0400 Received: from mail1.hce-engineering.it ([104.233.86.154]:36490 "EHLO mail1.hce-engineering.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750949AbcGNMrO (ORCPT ); Thu, 14 Jul 2016 08:47:14 -0400 X-Greylist: delayed 2503 seconds by postgrey-1.27 at vger.kernel.org; Thu, 14 Jul 2016 08:47:14 EDT To: Jiri Slaby , akpm@linux-foundation.org References: <20160714115245.12651-1-jslaby@suse.cz> Cc: linux-kernel@vger.kernel.org From: Rodolfo Giometti Message-ID: <57877FEE.6020405@enneenne.com> Date: Thu, 14 Jul 2016 14:05:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <20160714115245.12651-1-jslaby@suse.cz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 88.147.3.120 X-SA-Exim-Mail-From: giometti@enneenne.com Subject: Re: [PATCH -resend] pps: do not crash when failed to register X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on hce1.hce-engineering.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/14/16 13:52, Jiri Slaby wrote: > With this command sequence: > modprobe plip > modprobe pps_parport > rmmod pps_parport > the partport_pps modules causes this crash: > > === > > BUG: unable to handle kernel NULL pointer dereference at (null) > IP: [] parport_detach+0x1d/0x60 [pps_parport] > Oops: 0000 [#1] SMP > ... > Call Trace: > [] parport_unregister_driver+0x65/0xc0 [parport] > [] SyS_delete_module+0x187/0x210 > > === > > 1) plip is loaded and takes the parport device for exclusive use: > plip0: Parallel port at 0x378, using IRQ 7. > > 2) pps_parport then fails to grab the device: > pps_parport: parallel port PPS client > parport0: cannot grant exclusive access for device pps_parport > pps_parport: couldn't register with parport0 > > 3) rmmod of pps_parport is then killed because it tries to access > pardev->name, but pardev (taken from port->cad) is NULL. > > So add a check for NULL in the test there too. > > Signed-off-by: Jiri Slaby > Cc: Rodolfo Giometti > --- > drivers/pps/clients/pps_parport.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c > index 38a8bbe74810..83797d89c30f 100644 > --- a/drivers/pps/clients/pps_parport.c > +++ b/drivers/pps/clients/pps_parport.c > @@ -195,7 +195,7 @@ static void parport_detach(struct parport *port) > struct pps_client_pp *device; > > /* FIXME: oooh, this is ugly! */ > - if (strcmp(pardev->name, KBUILD_MODNAME)) > + if (!pardev || strcmp(pardev->name, KBUILD_MODNAME)) > /* not our port */ > return; > > Acked-by: Rodolfo Giometti -- HCE Engineering e-mail: giometti@hce-engineering.com GNU/Linux Solutions giometti@enneenne.com Linux Device Driver giometti@linux.it Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti Cosino Project - the quick prototyping embedded system - www.cosino.io Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it