From patchwork Thu Nov 8 09:55:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Northup X-Patchwork-Id: 1714821 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2C90BDF280 for ; Thu, 8 Nov 2012 09:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755188Ab2KHJ4e (ORCPT ); Thu, 8 Nov 2012 04:56:34 -0500 Received: from mail-wi0-f202.google.com ([209.85.212.202]:39178 "EHLO mail-wi0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753974Ab2KHJ4c (ORCPT ); Thu, 8 Nov 2012 04:56:32 -0500 Received: by mail-wi0-f202.google.com with SMTP id hr7so168394wib.1 for ; Thu, 08 Nov 2012 01:56:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=v4TUxVPP/ey+QTS8y8RExVXTrKrLXZOopaRuXAWeWqE=; b=OATbMVCfB7kXI5YW/F/S38bxrvZsAFLxkafe0HQElah518c9URTVMv/eayEVy3Asqi 87ZW+oM2ccCAXXOzqjmuCRO9JxvCDRk5bIHDRcwIlnGGNVstqE5iAbj4fsc7Ou5GisCx +QDHiXGdhS6nH7RRjh3H8FczktX1jSQ2jiMb8iEe9JdBQNtEfUkimCdn1bYM5+NBajVR OPAbXycytb0SzXAIFP6UskE5cxiU0NjRkyxI/0s8sKb9m0ZkMO3rMkw3UrFjYuaI27w8 GKcTuQ2BCxSH+aXkb8cmmv2vx/B70oAO2PnMe1p06cM2dq8qTZ3+AqdjwHmoxx0WS/vN vm9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=v4TUxVPP/ey+QTS8y8RExVXTrKrLXZOopaRuXAWeWqE=; b=kxQVmRJphZA+TtBJJ+iORwp2CYPoRjzT3fu8BmUUMwvSAWVYxB1hEAVEY/7H3tgdyO +Wcyu+bqu53xdz/EyfIsrt723TkM1NixVFwG8lfGpwb7lxskdIbyKLTpfW4tna8ElWlF wk79IxFYLBeMeS/uRjOrq0VWCiRtNq8tlEvYB+TNsTRL5vzaMa04Lv3QVlL0Sw2vohk6 PHk+50XPjJISQO08g2zz2CNb2E0YQFVj+Qy+BBG72itD0xcYSEu+MCDODtOOH25ad/mu gxmM3KJCrTYpZqSaAJn2ezV1KyKJwYmKwBX36rM8ecmXbi/1kZVHCt3AWS6MW22fkO9p Cq8Q== Received: by 10.14.199.6 with SMTP id w6mr8070782een.0.1352368590874; Thu, 08 Nov 2012 01:56:30 -0800 (PST) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id z47si5185690eel.0.2012.11.08.01.56.30 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 08 Nov 2012 01:56:30 -0800 (PST) Received: from digitaleric1.sea.corp.google.com (digitaleric1.sea.corp.google.com [172.31.88.125]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id 7FC3D5C0050; Thu, 8 Nov 2012 01:56:30 -0800 (PST) Received: by digitaleric1.sea.corp.google.com (Postfix, from userid 107025) id 53686C0494; Thu, 8 Nov 2012 01:56:29 -0800 (PST) From: Eric Northup To: Paolo Bonzini Cc: "James E.J. Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Eric Northup Subject: [PATCH] virtio_scsi: fix memory leak on full queue condition. Date: Thu, 8 Nov 2012 01:55:50 -0800 Message-Id: <1352368550-6694-1-git-send-email-digitaleric@google.com> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQl1AaQPkhsv2sjFCK83h0swZ+psRCAM1inM7xvG4dWabDieKbIfLZAdE4e8QVmDdnOaCyPWqb9WHh790UOko8erGWH3PE1JorjW1gNZTglGbAmMFf8asP/VTaoGaRutMWXSVqBO2k3bPmuygChpWp8drXuIRI+yxocQik0+eEuy/iKESjOwsviQdAuHkymqewepAM7P Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org virtscsi_queuecommand was leaking memory when the virtio queue was full. Tested: Guest operates correctly even with very small queue sizes, validated we're not leaking kmalloc-192 sized allocations anymore. Signed-off-by: Eric Northup Acked-by: Paolo Bonzini --- drivers/scsi/virtio_scsi.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 595af1a..dd8dc27 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -469,6 +469,8 @@ static int virtscsi_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc) sizeof cmd->req.cmd, sizeof cmd->resp.cmd, GFP_ATOMIC) >= 0) ret = 0; + else + mempool_free(cmd, virtscsi_cmd_pool); out: return ret;