Message ID | 20180214201154.10186-4-willy@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, 2018-02-14 at 12:11 -0800, Matthew Wilcox wrote: > From: Matthew Wilcox <mawilcox@microsoft.com> > > Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> > --- > drivers/char/virtio_console.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index 468f06134012..e0816cc2c6bd 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -433,8 +433,7 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, > * Allocate buffer and the sg list. The sg list array is allocated > * directly after the port_buffer struct. > */ > - buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages, > - GFP_KERNEL); > + buf = kvzalloc_struct(buf, sg, pages, GFP_KERNEL); > if (!buf) > goto fail; kvfree?
On Wed, Feb 14, 2018 at 12:19:47PM -0800, Joe Perches wrote: > On Wed, 2018-02-14 at 12:11 -0800, Matthew Wilcox wrote: > > */ > > - buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages, > > - GFP_KERNEL); > > + buf = kvzalloc_struct(buf, sg, pages, GFP_KERNEL); > > if (!buf) > > kvfree? Yes, that would also need to be done. The point of these last six patches was to show the API in use, not for applying.
On Wed, 2018-02-14 at 12:28 -0800, Matthew Wilcox wrote: > On Wed, Feb 14, 2018 at 12:19:47PM -0800, Joe Perches wrote: > > On Wed, 2018-02-14 at 12:11 -0800, Matthew Wilcox wrote: > > > */ > > > - buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages, > > > - GFP_KERNEL); > > > + buf = kvzalloc_struct(buf, sg, pages, GFP_KERNEL); > > > if (!buf) > > > > kvfree? > > Yes, that would also need to be done. The point of these last six > patches was to show the API in use, not for applying. That's what RFC is for...
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 468f06134012..e0816cc2c6bd 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -433,8 +433,7 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, * Allocate buffer and the sg list. The sg list array is allocated * directly after the port_buffer struct. */ - buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages, - GFP_KERNEL); + buf = kvzalloc_struct(buf, sg, pages, GFP_KERNEL); if (!buf) goto fail;