Commit bf953917 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'kspp-misc-fixes-5.16-rc1' of...

Merge tag 'kspp-misc-fixes-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux

Pull hardening fixes and cleanups from Gustavo A. R. Silva:
 "Various hardening fixes and cleanups that I've been collecting during
  the last development cycle:

  Fix -Wcast-function-type error:

   - firewire: Remove function callback casts (Oscar Carter)

  Fix application of sizeof operator:

   - firmware/psci: fix application of sizeof to pointer (jing yangyang)

  Replace open coded instances with size_t saturating arithmetic
  helpers:

   - assoc_array: Avoid open coded arithmetic in allocator arguments
     (Len Baker)

   - writeback: prefer struct_size over open coded arithmetic (Len
     Baker)

   - aio: Prefer struct_size over open coded arithmetic (Len Baker)

   - dmaengine: pxa_dma: Prefer struct_size over open coded arithmetic
     (Len Baker)

  Flexible array transformation:

   - KVM: PPC: Replace zero-length array with flexible array member (Len
     Baker)

  Use 2-factor argument multiplication form:

   - nouveau/svm: Use kvcalloc() instead of kvzalloc() (Gustavo A. R.
     Silva)

   - xfs: Use kvcalloc() instead of kvzalloc() (Gustavo A. R. Silva)"

* tag 'kspp-misc-fixes-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux:
  firewire: Remove function callback casts
  nouveau/svm: Use kvcalloc() instead of kvzalloc()
  firmware/psci: fix application of sizeof to pointer
  dmaengine: pxa_dma: Prefer struct_size over open coded arithmetic
  KVM: PPC: Replace zero-length array with flexible array member
  aio: Prefer struct_size over open coded arithmetic
  writeback: prefer struct_size over open coded arithmetic
  xfs: Use kvcalloc() instead of kvzalloc()
  assoc_array: Avoid open coded arithmetic in allocator arguments
parents a5a9e006 ebe4560e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ struct kvmppc_spapr_tce_table {
	u64 size;		/* window size in pages */
	struct list_head iommu_tables;
	struct mutex alloc_lock;
	struct page *pages[0];
	struct page *pages[];
};

/* XICS components, defined in book3s_xics.c */
+1 −2
Original line number Diff line number Diff line
@@ -295,8 +295,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
		return ret;

	ret = -ENOMEM;
	stt = kzalloc(sizeof(*stt) + npages * sizeof(struct page *),
		      GFP_KERNEL);
	stt = kzalloc(struct_size(stt, pages, npages), GFP_KERNEL);
	if (!stt)
		goto fail_acct;

+1 −2
Original line number Diff line number Diff line
@@ -742,8 +742,7 @@ pxad_alloc_desc(struct pxad_chan *chan, unsigned int nb_hw_desc)
	dma_addr_t dma;
	int i;

	sw_desc = kzalloc(sizeof(*sw_desc) +
			  nb_hw_desc * sizeof(struct pxad_desc_hw *),
	sw_desc = kzalloc(struct_size(sw_desc, hw_desc, nb_hw_desc),
			  GFP_NOWAIT);
	if (!sw_desc)
		return NULL;
+26 −6
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/firewire.h>
#include <linux/firewire-cdev.h>
@@ -953,11 +954,25 @@ static enum dma_data_direction iso_dma_direction(struct fw_iso_context *context)
			return DMA_FROM_DEVICE;
}

static struct fw_iso_context *fw_iso_mc_context_create(struct fw_card *card,
						fw_iso_mc_callback_t callback,
						void *callback_data)
{
	struct fw_iso_context *ctx;

	ctx = fw_iso_context_create(card, FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL,
				    0, 0, 0, NULL, callback_data);
	if (!IS_ERR(ctx))
		ctx->callback.mc = callback;

	return ctx;
}

static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
{
	struct fw_cdev_create_iso_context *a = &arg->create_iso_context;
	struct fw_iso_context *context;
	fw_iso_callback_t cb;
	union fw_iso_callback cb;
	int ret;

	BUILD_BUG_ON(FW_CDEV_ISO_CONTEXT_TRANSMIT != FW_ISO_CONTEXT_TRANSMIT ||
@@ -970,7 +985,7 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
		if (a->speed > SCODE_3200 || a->channel > 63)
			return -EINVAL;

		cb = iso_callback;
		cb.sc = iso_callback;
		break;

	case FW_ISO_CONTEXT_RECEIVE:
@@ -978,19 +993,24 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
		    a->channel > 63)
			return -EINVAL;

		cb = iso_callback;
		cb.sc = iso_callback;
		break;

	case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
		cb = (fw_iso_callback_t)iso_mc_callback;
		cb.mc = iso_mc_callback;
		break;

	default:
		return -EINVAL;
	}

	if (a->type == FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL)
		context = fw_iso_mc_context_create(client->device->card, cb.mc,
						   client);
	else
		context = fw_iso_context_create(client->device->card, a->type,
			a->channel, a->speed, a->header_size, cb, client);
						a->channel, a->speed,
						a->header_size, cb.sc, client);
	if (IS_ERR(context))
		return PTR_ERR(context);
	if (client->version < FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW)
+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ static int alloc_init_cpu_groups(cpumask_var_t **pcpu_groups)
	if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
		return -ENOMEM;

	cpu_groups = kcalloc(nb_available_cpus, sizeof(cpu_groups),
	cpu_groups = kcalloc(nb_available_cpus, sizeof(*cpu_groups),
			     GFP_KERNEL);
	if (!cpu_groups) {
		free_cpumask_var(tmp);
Loading