Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754893AbaDNNGU (ORCPT ); Mon, 14 Apr 2014 09:06:20 -0400 Received: from vserver.eikelenboom.it ([84.200.39.61]:37305 "EHLO smtp.eikelenboom.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754745AbaDNNGQ (ORCPT ); Mon, 14 Apr 2014 09:06:16 -0400 Date: Mon, 14 Apr 2014 15:06:11 +0200 From: Sander Eikelenboom Organization: Eikelenboom IT services X-Priority: 3 (Normal) Message-ID: <195733186.20140414150611@eikelenboom.it> To: Christoph Hellwig CC: linux-kernel , linux-scsi@vger.kernel.org Subject: Re: 3.15-mw: Oops Workqueue: writeback bdi_writeback_workfn (flush-8:16) RIP: e030:[] [] kobject_put+0x11/0x70 In-Reply-To: <20140414113015.GA4765@infradead.org> References: <1299097701.20140412133431@eikelenboom.it> <20140414113015.GA4765@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Monday, April 14, 2014, 1:30:15 PM, you wrote: > On Sat, Apr 12, 2014 at 01:34:31PM +0200, Sander Eikelenboom wrote: >> Hi, >> >> I just ran into the oops belowafter some uptime. > Classic use after free introduced by my recent changes, sorry. > This should fix it: Thx ! > --- > From: Christoph Hellwig > Subject: scsi: don't reference freed command in scsi_init_sgtable > When scsi_init_io fails we have to release our device reference, but > we do this trying to reference the just freed command. Add a local > scsi_device pointer to fix this. > Reported-by: Sander Eikelenboom > Signed-off-by: Christoph Hellwig > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index 65a123d..54eff6a 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -1044,6 +1044,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, > */ > int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) > { > + struct scsi_device *sdev = cmd->device; > struct request *rq = cmd->request; > > int error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask); > @@ -1091,7 +1092,7 @@ err_exit: > scsi_release_buffers(cmd); > cmd->request->special = NULL; > scsi_put_command(cmd); > - put_device(&cmd->device->sdev_gendev); > + put_device(&sdev->sdev_gendev); > return error; > } > EXPORT_SYMBOL(scsi_init_io); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/