lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 25 Jan 2014 17:59:32 -0200
From:	Leandro Dorileo <l@...ileo.org>
To:	linux-kernel@...r.kernel.org
Cc:	virtio-dev@...ts.oasis-open.org,
	virtualization@...ts.linux-foundation.org, rusty@...tcorp.com.au,
	mst@...hat.com, Leandro Dorileo <l@...ileo.org>
Subject: [PATCH] virtio_balloon: don't call virtio_has_feature() twice on init_vqs()

Cchange init_vqs() to avoid calling twice the virtio_has_feature()
- attempting to find out if VIRTIO_BALLOON_F_STATS_VQ feature was negotiated -
consequently we prevent unnecessarily running the drivers' feature_table more
than needed.

Signed-off-by: Leandro Dorileo <l@...ileo.org>
---
 drivers/virtio/virtio_balloon.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 34bdaba..41771c1 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -320,19 +320,21 @@ static int init_vqs(struct virtio_balloon *vb)
 	vq_callback_t *callbacks[] = { balloon_ack, balloon_ack, stats_request };
 	const char *names[] = { "inflate", "deflate", "stats" };
 	int err, nvqs;
+	bool stats;
 
 	/*
 	 * We expect two virtqueues: inflate and deflate, and
 	 * optionally stat.
 	 */
-	nvqs = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) ? 3 : 2;
+	stats = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ);
+	nvqs = stats ? 3 : 2;
 	err = vb->vdev->config->find_vqs(vb->vdev, nvqs, vqs, callbacks, names);
 	if (err)
 		return err;
 
 	vb->inflate_vq = vqs[0];
 	vb->deflate_vq = vqs[1];
-	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) {
+	if (stats) {
 		struct scatterlist sg;
 		vb->stats_vq = vqs[2];
 
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ