From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967196AbcHBN7U (ORCPT ); Tue, 2 Aug 2016 09:59:20 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:35585 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966121AbcHBN7L (ORCPT ); Tue, 2 Aug 2016 09:59:11 -0400 From: Wei Yongjun To: "Michael S . Tsirkin" Cc: Wei Yongjun , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH -next] virtio: fix possible memory leak in virtqueue_add() Date: Tue, 2 Aug 2016 13:59:05 +0000 Message-Id: <1470146345-19531-1-git-send-email-weiyj.lk@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org desc may malloced in virtqueue_add() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Signed-off-by: Wei Yongjun --- drivers/virtio/virtio_ring.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 114a0c8..bda71ef 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -328,6 +328,7 @@ static inline int virtqueue_add(struct virtqueue *_vq, if (out_sgs) vq->notify(&vq->vq); END_USE(vq); + kfree(desc); return -ENOSPC; }